From this question & the answers - What is the correct answer for cout << c++ << c;?
I get that
std::cout<<c++<<c;
is evaluated as:
std::operator<<(std::operator<<(std::cout, c++), c);
so the undefined behavior comes from the fact that either of the two parameters could be evaluated first. So far so good.
But why std::operator <<
? Why isn't std::ostream::operator <<
called? And if it is, wouldn't it translate to
(ofstream::operator<<(c++)) << c;
|
returns ofstream&
What's the difference between this and method chaining:
struct A
{
A& foo();
void goo();
};
//...
A a;
a.foo().goo();
?