问题
填空题
有以下复数类的声明,请补充完整。
Class complex
double real;//实部
double imag;//虚部
public:
complex(double x,double y)
real=x:
imag=y;
complex operator+(complex e) //重载加法运算符“+”
return complex(______)
;
答案
参考答案:real+c.real,imag+c.imag
解析: 在复数类中进行+运算符成员函数重载,是复数的实部和虚部分别相加。