Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which operator must be a member function?

  1. operator+

  2. operator-

  3. operator=

  4. operator*

The correct answer is: 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=.