Re: operator<< overloading
It is equivalent to:
Code:
A.operator<<(B).operator<<("test").operator<<(C);
:)
Or in other words:
Code:
Object& ref1 = A.operator<<(B);
Object& ref2 = ref1.operator<<("test");
Object& ref3 = ref2.operator<<(C);
Re: operator<< overloading
Neiter A nor B, but
Code:
((A.operator<<(B)).operator<<(Object("test"))).Operator<<(C);
So it will run A << B, store the result in a temp and then run temp << Object("test"), and so on.
Re: operator<< overloading
Quote:
If the correct equivalent is A, this is wrong, because you don't NEED to return the object for that.
You should test your hypothesis with an example program where operator<< returns void and yet you attempt operator chaining. After that contrapositive logic will show you that the correct equivalent is not A, as Zaccheus and treuss have noted.
Re: operator<< overloading
Thank you so much to all of you for your responses. You helped me a lot and I understand now why I was mistaken...
:)
Take care.
Re: operator<< overloading
Good that you understood..But I thing I still dont understand is why you have overloaded operator<< in the first place that way.