#include<iostream.h>
#include<conio.h>
class Integer
{
int a;
public:
void accept()
{
cout<<"\n\nEnter a number : ";
cin>>a;
}
Integer operator +(Integer s)
{
Integer temp;
temp.a=a+s.a;
return temp;
}

Integer operator -(Integer s)
{
Integer temp;
temp.a=a-s.a;
return temp;
}
Integer operator *(Integer s)
{
Integer temp;
temp.a=a*s.a;
return temp;
}
Integer operator /(Integer s)
{
Integer temp;
temp.a=a/s.a;
return temp;
}
void disp()
{
cout<<a<<"\t";
}
};
int main()
{
clrscr();
Integer b1,b2,b3;
b1.accept();
b2.accept();
cout<<"\nFirst number:";
b1.disp();
cout<<"\nSecond number:";
b2.disp();
cout<<"\n\nAddition is       : ";
b3=b1+b2;
b3.disp();
cout<<"\n\nSubtraction is    : ";
b3=b1-b2;
b3.disp();
cout<<"\n\nMultiplication is : ";
b3=b1*b2;
b3.disp();
cout<<"\n\nDivision is       : ";
b3=b1/b2;
b3.disp();
getch();
return(0);

Post a Comment

Previous Post Next Post