64,637
社区成员
发帖
与我相关
我的任务
分享
class complex
{
public:
complex(double r =0 , double i= 0) : re(r), im(i) {}
~complex(void) {}
protected:
friend inline complex operator+(const complex& x, const complex& y) {
return complex(x.re+y.re, x.im+y.im);
}
public:
double re, im;
};
int main() {
complex a(1,1), b(2,2);
complex c = a + b;
cout << c.re << "\t" << c.im << endl;
return 0;
}