// 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 re, im; public: complex(double r = 0, double i = 0) : re{r}, im{i} { } double real() const { return re; } double imag() const { return im; } complex& operator=(complex other) { re = other.re; im = other.im; return *this; } complex& operator+=(complex other) { re += other.re; im += other.im; 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.imag() == b.imag(); }