#include <iostream> #include <cmath> using namespace std; class Complex{ public: Complex(double a=0,double b=0); Complex(Complex &c); void add(Complex p); void show(); double mod(); private: double x,y; }; Complex::Complex(double a,double b){ x=a; y=b; } Complex::Complex(Complex &c){ x=c.x; y=c.y; } void Complex::add(Complex c){ x=c.x+x; y=c.y+y; } void Complex::show(){ cout<<x<<"+"<<y<<"i"<<endl; } double Complex::mod(){ return sqrt(pow(x,2)+pow(y,2)); } int main(){ Complex c1(3,5); Complex c2(4.5); Complex c3(c1); c1.add(c2); c1.show(); cout<<c1.mod(); return 0; }