#include <iostream.h> class Complex { double re; double im; public: Complex(double r,double i):re(r), im(i) { }; Complex( ) { re = 0; im = 0; } friend Complex operator+( const Complex &obj1, const Complex &obj2 ); friend Complex operator-( const Complex &obj1, const Complex &obj2 ); void print(); }; Complex operator+( const Complex &obj1, const Complex &obj2 ) { Complex temp; temp.re = obj1.re + obj2.re; temp.im = obj1.im + obj2.im; return temp; } Complex operator-( const Complex &obj1, const Complex &obj2 ) { Complex temp; temp.re = obj1.re - obj2.re; temp.im = obj1.im - obj2.im; return temp; } void Complex::print() { cout << re; if(im > 0) cout << "+" << im << "i" << endl; else cout << im << "i" << endl; } void main( ) { Complex obj1(1,2),obj2(3,4); Complex obj3 = obj1 + obj2; obj3.print(); cout<<endl; Complex obj4 = obj1 - obj2; obj4.print(); cout<<endl; }