Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Base {
- public:
- void fun()
- {
- cout << "void" << endl;
- }
- void fun(int i)
- {
- cout << "Base" << endl;
- }
- };
- class Derived : public Base {
- public:
- //using Base::fun; // comment/uncomment this line
- int fun(char c)
- {
- cout << "Derived" << endl;
- return 0;
- }
- };
- int main()
- {
- Derived d;
- //d.fun(); // error unless uncomented 'using' line in Derived class
- d.Base::fun();
- d.fun(1);
- d.Base::fun(1);
- d.fun('a');
- return 0;
- }
Add Comment
Please, Sign In to add comment