#include <iostream.h>
class Complex
{
private:
double r;
double i;
public:
Complex(double x=0.0,double y=0.0)
{
r=x;
i=y;
}
Complex operator+(const Complex &c);
friend Complex operator-(const Complex &c1,const Complex &c2);
void print();
};
Complex Complex::operator+(const Complex &c)
{
Complex t;
t.r=r+c.r;
t.i=i+c.i;
return t;
}
Complex operator-(const Complex &c1,const Complex &c2)
{
Complex t;
t.r=c1.r-c2.r;
t.i=c1.i-c2.i;
return t;
}
void Complex::print()
{
cout<<"("<<r<<","<<i<<")"<<endl;
}
void main()
{
Complex a(3.0,4.0),b(10.5,20.5),c;
c=a+b;
c.print();
c=a-b;
c.print();
}