求助 关于重载运算符
Class X{
.....
friend ostream &operator<<( ostream &,const Complex & );//语法错误 : 缺少“;”(在“&”的前面)//“ostream”: 不允许在数据声明中使用“friend”//语法错误: 标识符“ostream”
friend istream &operator>>( istream &, Complex & );
}
ostream &operator<<( ostream &output, const Complex & c)
{
output<<c.real<<"+"<<c.imaginary<<"i"<<endl;
return output;
}
istream &operator>>( istream &input, Complex & c)
{
input>>c.real;
input>>c.imaginary;
return input;
}