Line 7 doesn't work because qDebug() << is code that needs to be executed, so it needs to be on an execution code path.
For the variable name hiding: usually it is a bad idea to have local names that hide names on a more wider scope, for global or member variables that is usually solved by marking them explicitly as such.
E.g.
class Foo {
private:
int m_value; // using m_ prefix to say this is a member variable
};
class Foo {
private:
int m_value; // using m_ prefix to say this is a member variable
};
To copy to clipboard, switch view to plain text mode
If you really need a global variable with such a common names as "value" you can put it into a namespace, e.g.
namespace {
int value; // access through ::value
}
namespace globalvalues {
int value; // access through globalvalues::value
}
namespace {
int value; // access through ::value
}
namespace globalvalues {
int value; // access through globalvalues::value
}
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks