Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class A
- {
- public:
- void display() {}
- };
- class B : public A
- {
- public:
- virtual void display()
- {
- cout << "\nDisplay function of B Class";
- }
- };
- class C : public A
- {
- public:
- virtual void display()
- {
- cout << "\nDisplay function of C Class";
- }
- };
- class D: public B, public C{
- public:
- void display(){
- cout << "\nDisplay function of D Class, since B & C class have virtual functions";
- }
- };
- int main()
- {
- B *aa;
- D obj;
- aa= &obj;
- aa->display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement