ostream operator<<(ostream& os, class n);
I need to know whats happening inside and why it doesnt work if the return type is not a reference. And I need some links to good articles about istreams and ostreams that help me understand them (not too complicated articles please :D:D) thank you very much.
UPDATE 1: please remember to share links for articles so I can learn more about ostream and istream objects. thank you.
std::ostream‘s copy constructor is private – which means you cannot create a copy of a stream object.Each stream has an associated underlying buffer – which handles the reads/writes (for example
filebufmanages the reads/writes to files). If you were to make a copy of the stream, what do you propose to do with this underlying buffer? You cannot copy it, because then you would have two buffers (maintaining separate positional information – e.g. where it’s written to) – imagine the havoc… If you “move” it – i.e. transfer the ownership, there is the potential that you could quite conceivably loose the buffer (if copied to some scoped stream – say you pass it by value to a function and don’t return it), then what happens? It’s for complications like these, it makes sense to make this object non-copyable…