I understand the concept of operator overloading but i dont understand what is going on if that makes sense. In this piece of code, why has cout been replaced with os and i dont understand what the first parameter means (ostream& os)
Please help me
cout is just one possible output stream, another common one is output to a disk file. The << operator will work with any of these ostreams.
In the code above the first parameter will be replaced by whichever stream the function is called on, which may commonly be cout, but doesn't have to be.
The reason why the return value is also an ostream (the same ostream in fact) is so that you can use this << operator as part of a longer line, where other variables will also be sent to the output stream.