actuall i want to ask why do we call by refrence and then return it in the following . i mean the changes must hav been reflected.
ostream%26amp; operator %26lt;%26lt;(ostream %26amp;os,const Base %26amp;obj)
{
os%26lt;%26lt;obj.strVal;
return os;
}
Help stream operator overloading in c++?
At the time of the return, the changes *have* been reflected in the stream "os".
Returning the non-const reference to the stream facilitates chaining of the "%26lt;%26lt;" operator. The most prevalent use of such chaining is when using cout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment