You must overload the statement for ostream, then you can use it naturally for an instance of any class that comes from this: fromstream, fstream (inherits from iostream, which inherits both istream and ostream), ostringstream and stringstream (inherits iostream too)
std::ostream& operator<<(std::ostream& os, const MyData&);
matja source
share