#include<iostream>
using namespace std;
class base
{
public:
int m;
void get_m()
{
cout<<"\n\n\t\tEnter the value of m :";
cin>>m;
}
void disp()
{
cout<<"\n\n\t\tm :"<<m;
}
};
class derived:public base
{
public:
int n,sum;
void get()
{
cout<<"\n\n\t\tEnter the value of n:";
cin>>n;
}
void disp1()
{
cout<<"\n\n\t\tn :"<<n;
}
void calc()
{
cout<<m<<"\n"<<n;
sum=0;
sum=m+n;
cout<<"\n\n\t\tThe sum is :"<<sum;
cout<<"\n";
}
};
int main()
{
derived d;
d.get_m();
d.disp();
d.get();
d.disp1();
d.calc();
return(0);
}
No comments:
Post a Comment