Difficulty: Easy
Correct Answer: Destructor
Explanation:
Introduction / Context:
C++ uses a special member function prefixed with a tilde (~
) as the object's destructor. It runs automatically when an object's lifetime ends and is used to release resources.
Given Data / Assumptions:
~CuriousTab()
.
Concept / Approach:
By definition, any member named ~ClassName
with no return type and no parameters is the class destructor.
Step-by-Step Solution:
1) Identify the tilde-prefixed member.2) Recognize destructor signature (no return type, no parameters).3) Conclude that it is the destructor.
Verification / Alternative check:
Add logging inside ~CuriousTab()
to observe it runs at scope exit or upon delete
.
Why Other Options Are Wrong:
Constructor is CuriousTab(...)
, not ~CuriousTab()
. “Default Destructor” is not standard terminology; here it is a user-defined destructor. It is not a function template.
Common Pitfalls:
Confusing compiler-generated defaulted destructor with a user-defined one; both are destructors nonetheless.
Final Answer:
Destructor
Discussion & Comments