All challenges
Multiple ChoiceBeginner 45s

operator<< as friend vs member

Why is `operator<<` for streams usually implemented as a non-member (often friend) function?
Options
  1. 1Because the left operand is the stream (std::ostream&), not your class, so it cannot be a member of your class.
  2. 2Because member operators cannot be overloaded for any operator that takes two arguments.
  3. 3Because friend functions are always faster than member functions due to inlining rules.
  4. 4Because operator<< is required by the standard to be a static member of the stream class.

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle