#include<iostream.
h>
#include<conio.h>
class calc
{
int a,b;
public:
calc(){
}
calc(int x, int y){
a = x;
b = y;
}
calc sum(calc p, calc q)
{
calc t;
t.a = p.a + q.a;
t.b = p.b + q.b;
return t;
}
void print(){
cout<<a<<"+"<<b<<"i"<<'\n';
}
friend calc diff(calc h, calc g){
calc e;
e.a = h.a - g.a;
e.b = h.b - g.b;
return e;
}
};
int main(){
clrscr();
calc c1(3,4),c2(5,6),c3,c4;
c1.print();
c2.print();
c3=c3.sum(c1,c2);
cout<<"the sum is ";
c3.print();
c4=diff(c2,c1);
cout<<"the difference is ";
c4.print();
getch();
return 0;
}
OUTPUT:
3+4i
5+6i
the sum is 8+10i
the difference is 2+2i