ProgrammingHardProduct-company MCQ pattern

Which C++ operator can be overloaded only as a non-static member function, never as a free function?

  1. A. ==
  2. B. +
  3. C. <<
  4. D. = (assignment)

Correct answer: D. = (assignment)

Assignment =, subscript [], call () and member access -> must be members. +, << and == are often written as free (friend) functions so that the left operand need not be the class type.

More OOP with C++ and Java questions

Exams that ask this topic