G++ compiler cannot distinguish variable and function with the same name? [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Class method and variable with same name, compile error in C++ not in Java? The G++ compiler would complain when my class member name and member function name are the same. It seems that whenever a variable name happens to be the same as a function name, the compiler would complain. In Java, it is not the case. I just wonder why the G++ compiler cannot distinguish a variable name from a function name since the