Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Base
- {
- public:
- virtual void print() { cout << "Base print" << endl;}
- };
- class DerivedA : public Base
- {
- public:
- virtual void print() { cout << "Derived_A print" << endl;}
- };
- class DerivedB : public DerivedA
- {
- public:
- virtual void print() {cout << "Derived_B print" << endl;}
- };
- int main()
- {
- DerivedB b;
- Base* ptr = &b;
- ptr->print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement