Difficulty: Easy
Correct Answer: Constructors can take arguments but destructors cannot.
Explanation:
Introduction / Context:
Special member functions govern object lifetime in C++. Constructors initialize a newly created object; destructors finalize and clean it up. Understanding the exact grammar constraints for these functions—such as whether they accept parameters, return values, or allow overloading—is essential for writing correct RAII-style code and for interpreting compiler errors accurately.
Given Data / Assumptions:
Concept / Approach:
Constructors may take parameters; that is precisely how you support configurable initialization (e.g., Vector(int n), String(const char*)). Destructors, by contrast, are declared with an empty parameter list and can never take arguments. Neither constructors nor destructors return a value (not even void). Overloading is permitted for constructors (multiple parameter lists), but there is exactly one destructor per class, optionally virtual, and it cannot be overloaded. Therefore, the only correct comparison in the options is that constructors can take arguments but destructors cannot.
Step-by-Step Solution:
Verification / Alternative check:
Attempt to declare ~C(int) → compile-time error. Define multiple constructors with distinct parameter lists → valid overloading. Attempt to give constructors/destructors a return type → rejected by the compiler.
Why Other Options Are Wrong:
A: flips the truth about parameters.
C: reverses overloading realities.
D: contradicts the rule that special members have no return type.
Common Pitfalls:
Final Answer:
Constructors can take arguments but destructors cannot.
Discussion & Comments