Que - Make a program by using hybrid inheritance?
#include<iostream>
using namespace std;
class first
{
public:
int num1, num2 ;
void getdata ()
{
cout<<"enter a number :-";
cin>>num1;
cout<<"enter a number :-";
cin>>num2;
}
void display_data()
{;
cout<<"enter numbers are "<<num1<<" "<<num2;
}
};
class second: virtual public first
{
public:
};
class third: virtual public first
{
public:
};
class fourth:public second, public third
{
public:
};
int main()
{
fourth ob;
ob.getdata();
ob.display_data();
return 0;
}
Result:-
Tags
Hybrid inheritance