← Quiz: Operators and Templates: all 10 questions
Quiz: Operators and Templates · Question 1 of 10
Why is operator<< usually a non-member (often friend) function?
Why is operator<< usually a non-member (often friend) function?
- A.It's faster
- B.Its left operand is the output stream, not your class
- C.Members can't return references
- D.It must be static
Answer & explanation
Correct answer: Its left operand is the output stream, not your class
cout << x means operator<<(cout, x), so it can't be a member of x's class.
Can you get the rest right without peeking?
Take the timed Quiz: Operators and Templates quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →