class Test {
bool isVal() const {
return isVal;
}
private:
bool isVal;
};
On Compiling this file it says
The quick answer is "because that's the way C++ works." C++ doesn't have a separate name space for member variables and member functions (ie, "methods") where Java (apparently, as I haven't tried this) does.
In any case, remember the old story about the guy who went to a doctor and said "Doc, it hurts when I do this." To which the doctor replied "well, don't do that!" This is a language peculiarity on its way to becoming a Dumb Programmer Trick.