Que - make a program for multiple inheritance?
#include<iostream>
using namespace std;
class a
{
protected:
int num1, num2 ;
public:
void getdata ()
{
cout<<"enter a number :";
cin>>num1 ;
cout<<"enter a number :";
cin>>num2 ;
}
void display ()
{
num1=num1+num2;
cout<<"sum of two numbers is: "<<num1;
}
};
class b
{
public:
b()
{
cout<<"multiple inheritance example\n";
}
};
class c: public a, public b
{
};
int main()
{
c ob;
ob. getdata ();
ob. display ();
return 0;
}
Result:-