#include<iostream.h>
#include<conio.h>
class num
{
private :
int a,b,c,d;
public:
void input(void);
void show(void);
num operator+(num);
};
void num ::input()
{
cout<<"\n Enter value for a,b,c and d:\n";
cin>>a>>b>>c>>d;
}
void num :: show()
{
cout<<"A="<<a <<"B="<<b <<"C="<<c <<"D="<<d<<"\n";
}
num num::operator +(num t)
{
num tmp;
tmp.a=a+t.a;
tmp.b=a+t.b;
tmp.c=a+t.c;
tmp.d=a+t.d;
return(tmp);
}
void main()
{
clrscr();
num X,Y,Z;
cout<<"\n Object X";
X.input();
cout<<"\n Object Y";
Y.input();
Z=X+Y;
cout<<"\nX: ";
X.show();
cout<<"\nY: ";
Y.show();
cout<<"\nZ: ";
Z.show();
getch();
}
No comments:
Post a Comment