Why is operator<< for printing a user-defined type to std::ostream usually written as a non-member (often friend) function?
Correct answer B. Because the left operand is the ostream, not an object of the user's class
A member operator always takes its own class as the left operand, so a member operator<< would require writing obj << cout. For cout << obj the left operand is std::ostream, which you cannot modify, so the operator is written as a free function taking (std::ostream&, const T&). It is made a friend only when it needs access to private members.
Answer checked How we write and check questions
Discussion