* /program to illustrate multiple inheritance./ *
#include < iostream > using namespace std;
class M
{
protected: int m;
public: void get(int);
};
class N
{
protected: int n;
public: void getdata(int);
};
class P: public M, public N
{
public: void display(void);
};
void M::get(int x)
{
m = x;
}
void N::getdata(int y)
{
n = y;
}
void P::display(void)
{
cout << "\nm=" << m;
cout << "\nn=" << n;
cout << "\nm * n:" << m * n;
}
int main()
{
P obj;
obj.get(10);
obj.getdata(20);
obj.display();
return 0;
}There is lot of confusion in multiple or multi-level inheritance as it should be for studying OOPs as inheritance is important for it.
