填空题
有如下复数类的声明,请补充完整。
class complex {
double real; //实部
double imag; //虚部
public:
complex(double x,double y) {
real=x;
imag=y;
}
complex operator +(complex c) { //重载加法运算符"+"
return complex( 【13】 );
}
};
【参考答案】
real+c.real,imag+c.imag或this->real+c.real,this->imag+c.imag,......
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)