答案 0 :(得分:1)
定义
std::ostream &operator<<(std::ostream &out, Foo const &x)
{
// write a representation of x to out
// you can use << on x's members
return out;
}
std::istream &operator>>(std::istream &in, Foo &x)
{
// read a representation of a Foo from in
// and use it to modify x
return in;
}
适当。
答案 1 :(得分:0)
您不仅要定义operator >>
或operator <<
吗?