We had a class where professor asked us to overload ostream
to print object this way (saying we have object t)
cout << t << endl;
Then we were asked to cout the same object this way
t << cout << endl;
How does this work and why?
ostream& operator<<(ostream& o, T& t)
{
return o << t.member;
}
// This is usual way and "normal" that I know about but won't work on both ways
Expected output is the same, but second way is confusing. Why would anyone want to use it?