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 happens when a new object is initialized with an '=' operator, as in MyType a = b;?

  1. Copy constructor is called

  2. Default constructor is called

  3. Assignment operator is called

  4. Destructor is called

The correct answer is: Copy constructor is called

When a new object is initialized with an '=' operator, the copy constructor is called instead of the assignment operator. This is because the object being created is not yet initialized and cannot be assigned to using the assignment operator. The default constructor and destructor are not called because they are only used when creating and destroying objects, respectively. Therefore, options B, C, and D are incorrect.