Hi,
The following class containing a member and a method with the same
name will not compile:
class Test {
private:
bool x;
public:
Test() : x(true) {};
bool x() const {return x;}
};
I am not advocating writing code like the above, but I was puzzled by
the compiler's reason for rejecting it: It said there were multiple
declarations of Test::x.
Since methods and members can always be distinguished syntactically
when they are used, it seems strange that they cannot have the same
name. Just curious why this is?
thanks for any explanations,
cpp