as

Write a C++ program to demonstrate Hybrid inheritance.

Write a C++ program to demonstrate Hybrid inheritance.   

Inheritance types

1. Single inheritance
2. Multi Level inheritance
3. Multiple Level inheritance
 4. Hybrid inheritance

3. Hybrid inheritance :- 


Code :-

/**********program to implement inheritance (Hybrid inheritance)*****/
#include<iostream.h>
#include<conio.h>
class A
{
                public:
                void show_a()
                {
                                cout<<"\n\t Hello Class A \t";
                }
};
class B:virtual public A
{
                public:
                void show_b()
                {
                                cout<<"\n\t Hello Class B \t";
                }
};
class C:virtual public A
{
                public:
                void show_c()
                {
                                cout<<"\n\t Hello Class C \t";
                }
};
class D:public B, public C
{
                public:
                void show_d()
                {
                                cout<<"\n\t Hello Class D \t";
                }
};
void main()
{
                clrscr();
                D d1;
                d1.show_a();
                d1.show_b();
                d1.show_c();
                d1.show_d();
                getch();
}
/*
Output :-
                Hello Class A
                Hello Class B
                Hello Class C
                Hello Class D
*/


Output :-
Output :-
                Hello Class A
                Hello Class B
                Hello Class C
                Hello Class D