//Program to display add,sub,mult,divi by member function

| |


#include<iostream.h>
#include<conio.h>
class sample{
private:
int x;
int y;
public:
void getinfo();
void display();
int sum();
int diff();
int mult();
int div();
};
void sample::getinfo()
{
cout<<"enter any two no?"<<endl;
cin>>x>>y;
}
void sample::display()
{
cout<<"x="<<x<<endl;
cout<<"y="<<y<<endl;
cout<<"sum="<<sum()<<endl;
cout<<"diff="<<diff()<<endl;
cout<<"mult="<<mult()<<endl;
cout<<"div="<<div()<<endl;
}
int sample::sum()
{
return(x+y);
}
int sample::diff()
{
return(x-y);
}
int sample::mult()
{
return(x*y);
}
int sample::div()
{
return(x/y);
}
void main(void)
{
sample obj1;
obj1.getinfo();
obj1.display();
obj1.sum();
obj1.diff();
obj1.mult();
obj1.div();
}
<