Difficulty: Easy
Correct Answer: Destructor destroys the complete object.
Explanation:
Introduction / Context:
Destructors finalize objects by releasing resources and performing class-specific cleanup. A common misconception is that a destructor is tied to particular member types. In reality, destruction is holistic and ordered, covering all subobjects of the instance. This question asks which statement captures that behavior correctly.
Given Data / Assumptions:
Concept / Approach:
When a class’s destructor runs, the language guarantees that first the destructor body executes (your code), then class members are destroyed automatically in reverse order of their declaration, and finally base classes are destroyed last (again, reverse order relative to construction). Therefore, the entire object is torn down, not only specific member categories. If a class owns dynamic resources via pointers, the destructor should release them, but this is your policy code — not an automatic “pointer-only” rule.
Step-by-Step Solution:
Verification / Alternative check:
Instrument constructors and destructors of members and bases; observe paired creation/destruction logging that spans the full object graph, not just certain types like int or float.
Why Other Options Are Wrong:
“Only integer/float/pointer members” — destruction is not selective by type; all subobjects participate.
Common Pitfalls:
Final Answer:
Destructor destroys the complete object.
Discussion & Comments