// Complex Class as given in Ch. 4 of A Tour of C++, Bjarne Stroustrup, (both 2014 & 2018) // partial implementation, with differences from Stroustrup's version class complex { double _real_part, _imaginary_part; public: complex(double r = 0, double i = 0) : _real_part{r}, _imaginary_part{i} { } double real() const { return _real_part; } double imaginary() const { return _imaginary_part; } complex& operator=(complex other) { _real_part = other._real_part; _imaginary_part = other._imaginary_part; return *this; } complex& operator+=(complex other) { _real_part += other._real_part; _imaginary_part += other._imaginary_part; return *this; } }; complex operator+(complex a, complex b) { complex result; result = a; result += b; return result; } // DANGEROUS definition of == bool operator==(complex a, complex b) { return a.real() == b.real() && a.imaginary() == b.imaginary(); }