Name hiding (C++ only)
If a class name or enumeration name is in scope and not hidden, it is visible. A class name or enumeration name can be hidden by an explicit declaration of that same name — as an object, function, or enumerator — in a nested declarative region or derived class. The class name or enumeration name is hidden wherever the object, function, or enumerator name is visible. This process is referred to as name hiding.
In a member function definition, the declaration of a local name hides the declaration of a member of the class with the same name. The declaration of a member in a derived class hides the declaration of a member of a base class of the same name.
#include <iostream>
#include <typeinfo>
using namespace std;
namespace A {
char x;
};
namespace B {
using namespace A;
int x;
};
int main() {
cout << typeid(B::x).name() << endl;
}
See the output of the above example: int
The declaration of the integer x in namespace B hides the character x introduced by the using declaration.