Reputation: 615
I'm studying the overloading of operator<< and operator>>.
So I must use istream/ostream class to override.
But I don't understand why overridden operators take istream/ostream object by reference and return a reference.
Can you explain this?
Upvotes: 0
Views: 120
Reputation: 15172
It is done because stream types are not copyable and so that you can stack operations. std::cin >> num1 >> num2; and the like.
Upvotes: 1