#include using namespace std; class Complex { float real, imag; public: Complex() { real = 0; imag = 0; } Complex(float r, float i) { real = r; imag = i; } Complex operator+(Complex c) { Complex temp; temp.real = real + c.real; temp.imag = imag + c.imag; return temp; } Complex operator-(Complex c) { Complex temp; temp.real = real - c.real; temp.imag = imag - c.imag; return temp; } void operator-() { real = -real; imag = -imag; } bool operator==(Complex c) { return (real == c.real && imag == c.imag); } void display() { if (imag >= 0) cout << real << " + " << imag << "i" << endl; else cout << real << " - " << -imag << "i" << endl; } }; int main() { float r, i; cout << "Enter real and imaginary part of first number: "; cin >> r >> i; Complex c1(r, i); cout << "Enter real and imaginary part of second number: "; cin >> r >> i; Complex c2(r, i); Complex c3 = c1 + c2; Complex c4 = c1 - c2; cout << "\nc1 = "; c1.display(); cout << "c2 = "; c2.display(); cout << "c1 + c2 = "; c3.display(); cout << "c1 - c2 = "; c4.display(); if (c1 == c2) cout << "c1 and c2 are equal" << endl; else cout << "c1 and c2 are not equal" << endl; -c1; cout << "After unary minus, c1 = "; c1.display(); return 0; }