// complex number class class Complex { friend bool operator==(const Complex &a, const Complex &b); friend Complex operator+(const Complex &a, const Complex &b); friend Complex operator-(const Complex &a, const Complex &b); private: double real, imaginary; public: Complex( double r, double i = 0 ) : real(r), imaginary(i) {} Complex( Complex &c ) : real(c.real), imaginary(c.imaginary) {} }; // equality comparison of complex numbers bool operator==(const Complex &a, const Complex &b) { return a.real == b.real && a.imaginary == b.imaginary; } // addition of complex numbers Complex operator+(const Complex &a, const Complex &b) { Complex temp(0,0); temp.real = a.real + b.real; temp.imaginary = a.imaginary + b.imaginary; return temp; } // subtraction of complex numbers Complex operator-(const Complex &a, const Complex &b) { Complex temp(0,0); temp.real = a.real - b.real; temp.imaginary = a.imaginary - b.imaginary; return temp; }