编辑代码

#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; }
    bool operator < (const complex &r)const;

    private:
    double im;
    double re;
    friend void my_printf(complex & );

};

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);
}
inline bool 
complex::operator < (const complex &r)const{
    return this->re < r.re ?this->re:r.re;
}

template <class T>
inline const T&
min(const T& a,const T& b){
    return a<b?a:b;
}

void my_printf(complex & a){
    cout << a.im;
}

int main() {
    complex c1(2,1);
    complex c2(3,2);
    complex c3;

    c1 += c2;
    c1.real();
    complex c4(c2);
    c4.real();
    cout <<sizeof(complex)<<endl;
    cout <<sizeof(double)<<endl;
    cout << (c1<c2) << endl; 
    c3 = ::min<complex>(c1,c2);

    

	return 0;
}