Ace Your C++ Skills 2025 – Rock the ‘Thinking in C++’ Challenge!

Question: 1 / 565

Which operator must be a member function?

operator+

operator-

operator=

A member function is a function that is bound to a class, which means it is a function inside a class. This is also known as a method. In the context of overloading, a member functions has some keywords and symbols that are necessary. The operator= (assignment operator) must be a member function because it is used to define how the member variables of a class are assigned from one instance to another. The other operators listed as choices A, B, and D can all be non-member functions. A non-member function is not declared inside of a class and does not have access to the private data members of that class. While they can still operate on objects of a class, they do not have the same access and functionality as a member function. Therefore, the correct answer is C, the operator=.

Get further explanation with Examzify DeepDiveBeta

operator*

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy