We have seen the use of the scope resolution operator ( int x; class A { int x; virtual void someMethod() { x++; //increments the A::x ::x++; //increments the global x } }; What about using overloading and hiding?.. Example: class A{ public: virtual int f(int); }; class B: public A { public: virtual int f(char *); }; int main() { B b; b.f(2); //Error - B::f(char *) hides A::f(int) b.A::f(2); //fine b.f("test"); //fine } These notes are copyright Dr. Derek Molloy, School of Electronic Engineering, Dublin City University, Ireland 2013-present. Please contact him directly before reproducing any of the content in any way. |