class Test {
bool isVal() const {
return isVal;
}
private:
bool isVal;
};
On Compiling this file it says
C++ applies name mangling to function names and global variables. Local variables are not mangled. The problem arises because in C you can access the address of a variable or a function (thus in C++ as well) e.g. :
struct noob{
bool noobvar;
void noobvar(){};
};
One can say, why not apply name mangling to local variables as well and then have an internal local representation such as
bool __noobvar_avar;
void __noobvar_void_fun;
and suppose that they receive the addresses during execution 0x000A and 0x00C0 respectively.
However if we write somewhere in the code:
&noob::noobvar
What should the program do ?
You can see that since in C , and therefore in C++ , you can issue an "address of", it is not legal to have variables and functions with the same name within the same scope of resolution.