Difficulty: Easy
Correct Answer: ~
Explanation:
Introduction / Context:
Destructor syntax is intentionally simple and uniform across classes so programmers can quickly recognize cleanup code. The destructor name is derived from the class name using a specific prefix character.
Given Data / Assumptions:
Concept / Approach:
The destructor is written as ~ClassName(). For a class Widget, the destructor is ~Widget(). No return type or parameters are allowed. The leading character is the tilde symbol, not any other punctuation character.
Step-by-Step Solution:
1) Recall: constructor → Widget(); destructor → ~Widget().2) Note there is no return type and no parameters for the destructor.3) Identify the prefix character: ~ (tilde).4) Select the correct option accordingly.
Verification / Alternative check:
Compile a class with ~ClassName(); omitting the tilde or using other symbols leads to errors.
Why Other Options Are Wrong:
! ? $ #: not part of destructor syntax; using them will not compile.
Common Pitfalls:
Attempting to add a return type to ~ClassName or parameters; both are illegal in C++.
Final Answer:
~
Discussion & Comments