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

Question: 1 / 565

What happens when a new object is initialized with an '=' operator, as in MyType a = b;?

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.

Get further explanation with Examzify DeepDiveBeta

Default constructor is called

Assignment operator is called

Destructor is called

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy