Possible Duplicate:
Operator overloading运营商<<重载
我没有找到,可以帮助我在这个问题的任何东西...... 我尝试过负荷<< operator
,这是我的代码:
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
什么,为什么我做错了? 感谢
,而且这个免费函数通常会成为你的对象的“朋友”。 – AJG85