Hi forum

Take this example code:

Code:
class Object
{
public:

Object(const char *String);

Object &operator<<(const Object &LHS);
}

Object A, B, C, D;

A << B << "test" << C;
What would the last statement be equivalent to?

A)

Code:
A.operator<<(B);
Object Temp("test");
A.operator<<(Temp);
A.operator<<(C);
OR

B)

Code:
Object Temp("test");
A.operator<<( B.operator<<( Temp.Operator<<( C ) ) );
I believe it is A, but why then do so many tutorials on operator<<-overloading say something like:

"We have to return the [in this case class Object] object, since this allows us to chain multiple objects to be output on a single line (e.g.: A << "blah" << B << C; )."

If the correct equivalent is A, this is wrong, because you don't NEED to return the object for that. You would only have to return it for things like:

Code:
if( (A << B << C) == D) return;
Am I right or am I mistaken?

Any help is highly appreciated