#include #include using namespace std; class Complex { private: double re, im; public: Complex (double re_=0, double im_=0) : re(re_), im(im_) {} double real() { return (*this).re; } double imag() { return this->im; } double abs() { return sqrt( (*this).real()*(*this).real() + (this->imag())*(this->imag()) ); } }; int main() { Complex z{1.0, 2.0}; cout << "Re z = " << z.real() << " Im z = " << z.imag() << " |z| = " << z.abs() << endl; return 0; }