Hybrid Inheritance In cpp

Hybrid Inheritance In cpp

PROGRAM:
#include<iostream>
using namespace std;
class A{
     public:
    A(){
    cout<<"\n grand parent";
    }

};
class B:public A{
     public:
    B(){

    cout<<"\n parent1";
    }
};
class C:public A{
     public:
    C(){
    cout<<"\n parent2";
    }
};
class D:public B,public C{
     public:
    D(){
    cout<<"\n child class";
    }
};
int main(){
D d;
return 0;
}

 
 

Comments

Popular posts from this blog

Introduction to ChatGPT: Explain what ChatGPT is, how it works, and what it is used for.

Multi Level Inheritance In cpp

Inline Function In cpp