#include<iostream>
using namespace std;
class A
{
protected:
int m;
public:
void get_m(int);
};
void A::get_m(int x)
{
m=x;
}
class B
{
protected:
int n;
public:
void get_n(int);
};
void B::get_n(int y)
{
n=y;
}
class C:public A,public B
{
private:
int c;
public:
void add();
void disp();
};
void C::add()
{
c=m+n;
}
void C::disp()
{
cout<<"value of m is:"<<m<<endl;
cout<<"value of n is:"<<n<<endl;
cout<<"the sum is:"<<c<<endl;
}
int main()
{
C obj;
obj.get_m(10);
obj.get_n(56);
obj.add();
obj.disp();
}
No comments:
Post a Comment