编辑代码

#include <iostream>
using namespace std;

class complex{
    public:
    complex(double r = 0,double i = 0)
        :re(r),im(i)
        {}
    complex & operator += (const complex &r);
    complex & __drop(complex *ths,const complex &r);
    void real(){cout << re <<endl;cout <<im <<endl; }

    private:
    double im;
    double re;

};

inline complex &
complex:: __drop(complex *ths,const complex &r){
    ths->re += r.re;
    ths->im += r.im;
    return *ths;
}
inline complex & 
complex::operator += (const complex &r){
    return __drop(this,r);
}


int main() {
    complex c1(2,1);
    complex c2(3,2);
    c1 += c2;
    c1.real();
	return 0;
}