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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -