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 does operator delete do first?

  1. Releases memory

  2. Calls the destructor

  3. Checks if the pointer is null

  4. Calls malloc function

The correct answer is: Calls the destructor

When using the operator delete, the first step it takes is to call the destructor of the object being deleted. This is important because the destructor is responsible for cleaning up any resources allocated by the object. Options A and D are incorrect because they refer to the actual action of freeing up memory and do not specify the order in which the operator delete function operates. Option C is also incorrect because it refers to the check for a null pointer, which happens after the destructor is called. Therefore, the most accurate answer is B as it mentions the initial and crucial step of calling the destructor.