可能是重复问题:
运算符重载
我在这个主题中没有找到任何有助于我的东西……
我正在尝试重载 << 运算符
,这是我的代码:
ostream& Complex::operator<<(ostream& out,const Complex& b){
out<<"("<<b.x<<","<<b.y<<")";
return out;
}
这是H文件中的声明:
ostream& operator<<(ostream& out,const Complex& b);
我遇到了这个错误:
error: std::ostream& Complex::operator<<(std::ostream&, const Complex&) must take exactly one argument
我做错了什么,有什么原因吗?
谢谢。
friend
。 - AJG85