我只是在玩 + 运算符,我无法弄清楚如何声明它并“明确”使用它,请帮助代码如下:
class compex{
int real;
int img;
public:
compex();
compex(int,int);
compex& explicit operator + (const compex& P1)
friend ostream& operator <<(ostream& out,const compex& R);
};
运算符的实现是:
compex& compex :: operator + (const compex& P1)
{
this->real += P1.real;
this->img += P1.img;
return *this;
}