#include "complexNumber.h" using namespace std; complexNumber& complexNumber::operator+=(const complexNumber& other) { re += other.re; im += other.im; return *this; } complexNumber& complexNumber::operator*=(const complexNumber& other) { double temp_re = (re * other.re) - (im * other.im); im = (re * other.im) + (im * other.re); re = temp_re; return *this; } complexNumber operator+(complexNumber lhs, const complexNumber& rhs) { return lhs += rhs; } complexNumber operator*(complexNumber lhs, const complexNumber& rhs) { return lhs *= rhs; } bool operator==(const complexNumber& lhs, const complexNumber& rhs) { return (lhs.re == rhs.re) && (lhs.im == rhs.im); } ostream& operator<<(ostream& os, const complexNumber& c) { os << c.re << (c.im >= 0 ? " + " : " - ") << abs(c.im) << "i"; return os; }