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.


What is crucial for the proper functioning of chained expressions like a=b=c?

  1. Using a constructor

  2. Returning a constant reference

  3. Returning a new object each time

  4. Returning a non-const reference

The correct answer is: Returning a non-const reference

Chained expressions involve multiple assignments within a single statement. In order for these expressions to function properly, each assignment must have a valid and usable value to be assigned to the next assignment. Returning a non-const reference allows for the value to be passed on and used in subsequent assignments without creating a new object each time. This reduces the chances of errors occurring and ensures that the expression can be evaluated successfully. Options A, B, and C do not provide a valid and usable value for the next assignment, making them incorrect choices for the proper functioning of chained expressions.