Specifically why does declaring a method in a derived class hide all methods of the same name in the base class?
for instance why doesn't the following work:
intuitively one would think that ALL methods from a base class are inherited by a derived class, unless the derived class overloads the method, in which case ALL methods except the overloaded method is inherited.Code:class X { virtual void foo() { cout << "foo" << endl; }; }, class Y : public x { void foo( int x ) { cout << x << endl; }; void Test() { Y yClass; y.foo( 2 ); // okay works y.foo( ); // Error. X::foo() is hidden by Y::foo( int ) }
does anyone know why the behavior is different?
thanks
Zameer




Reply With Quote