When the output operator is overloaded, why return a reference to an iostream object, and not just an iostream object?

class A { public: int m_a; }; ostream& operator<<(ostream left, A a) { cout << a.m_a; return left; } 

    1 answer 1

    Objects of class std::ostream are not std::ostream . In this class, the copy constructor and the copy assignment operator are defined as deleted. Therefore, if you remove the link to the stream from the definition of the operator, the compiler will report an error.