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

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

Master C++ with our comprehensive quiz based on 'Thinking in C++'. Test your knowledge through flashcards and multiple-choice questions to enhance your understanding of C++. Prepare effectively for your exam!

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.


For assignment operators, what is returned to support assignment chaining like a=b=c?

  1. A constant reference

  2. A new object

  3. A non-const reference

  4. Void

The correct answer is: A non-const reference

When using assignment operators, the value of the final assignment is returned, which in this case is a non-const reference to support assignment chaining. Choosing A, B, or D would not allow for this capability. A constant reference cannot be reassigned, a new object would not have any relation to the original variable, and void cannot be used to assign a value. Therefore, the only correct choice is a non-const reference.