Practice mode C++

Which operator must be overloaded as a non-static member function in C++?

Correct answer A. operator= (assignment)

Explanation

The assignment operator =, along with subscript [], function call () and member access ->, must be overloaded as non-static member functions (C++23 relaxes this for () and [] only to allow static members). operator+, operator== and operator<< can be either members or free functions, and free functions are often preferred for symmetric binary operators.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.