#include using namespace std; class Complex { private: double real; double imag; public: Complex(double r, double i = 0) : real(r), imag(i) {} void add(const Complex &other) { real += other.real; imag += other.imag; } void show() const { cout << real; if (imag >= 0) cout << "+" << imag << "i" << endl; else cout << "-" << -imag << "i" << endl; } }; int main() { Complex c1(3, 5); Complex c2 = 4.5; cout << "c1="; c1.show(); cout << "c2="; c2.show(); c1.add(c2); cout << "c1+c2="; c1.show(); return 0; }