C++ inheritence calling base class member function using derived class -
may question wrong. new c++. there way call base class member function using derived class object if function being overridden in derived class?
for example:
class { public: void add() { cout<<"a"; } }; class b: public { public: void add() { cout<<"b"; } }; int main() { b bobj; bobj.add(); // calls member function of class b return 0; }
first of all, aren't overriding add
function, merely hiding name, since a::add
not declared virtual
.
to call a::add
, explicit it:
bobj.a::add();
Comments
Post a Comment