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.


When is the assignment operator used instead of a constructor?

  1. When initializing a new object

  2. When modifying an existing object

  3. When passing an object by value

  4. When returning an object from a function

The correct answer is: When modifying an existing object

The assignment operator, or "=", is used to modify an existing object. It is not used when initializing a new object, as this is done through a constructor. It is also not used when passing an object by value, as this involves the use of a copy constructor. Similarly, it is not used when returning an object from a function, as the return value would be assigned to a pre-existing object using the assignment operator. Therefore, the correct answer is B, when modifying an existing object.