问题
填空题
下面是复数类complex的定义,其中重载的运算符“+”的功能是返回一个新的复数对象,其实部等于两个操作对象实部之和,其虚部等于两个操作对象虚部之和;请补充完整:
class complex
double real; //实部
double imag; //虚部
public:
complex(double r, double i):real(r),imag(i)
complex operator+(complex a)
return complex(______);
;
答案
参考答案:real+a.real, imag+a.imag