August 2012
Intermediate to advanced
976 pages
30h 17m
English
We can use a hidden base-class member by using the scope operator:
struct Derived : Base { int get_base_mem() { return Base::mem; } // ...};
The scope operator overrides the normal lookup and directs the compiler to look for mem starting in the scope of class Base. If we ran the code above with this version of Derived, the result of d.get_mem() would be 0.
Best Practices
Aside from overriding inherited virtual functions, a derived class usually should not reuse names defined in its base class.
Read now
Unlock full access