#include <iostream>
using namespace std;class complex{ public: complex (double r= 0, double i = 0) :re (r) , im(i) { } complex operator += (const complex& c) { this->re = c.re + this->re; this->im = c.im + this->im; return * this; } double real () const {return re;} double imag () const {return im;} private: double re,im; friend complex&_dopal (complex*,const complex&); };ostream & operator<< (ostream & os, const complex& x){ return os<< '(' << x.real () <<',' << x.imag () <<'('; } //尽量不要 pass by value 引用就是一个指针int main(){ complex c(1,2), d(2,3),e(1,1),a(5,5); a += c += d; cout << a; return 0; }