ACtE03 · Chapter 3Programming & Applications🏛️ Past Licensure QuestionID: ce90add3
Which of the following statements regarding virtual constructors and destructors in C++ is TRUE?
Which of the following statements regarding virtual constructors and destructors in C++ is TRUE?
Multiple Choice Options
- A✓ Correct Option
A class can have a virtual destructor, but cannot have a virtual constructor
- B
A class can have a virtual constructor, but cannot have a virtual destructor
- C
A class can have both virtual constructors and virtual destructors
- D
Neither constructors nor destructors can ever be virtual
Detailed Technical Solution & Explanation
In C++, a constructor CANNOT be virtual because the virtual table pointer (vptr) is initialized by the constructor itself during object instantiation. A destructor CAN and often should be virtual to allow polymorphic deletion through base class pointers.
Option Analysis:
•
Option A (A class can have a virtual destructor...): Correct. Core C++ object model rule.
•
Option B (A class can have a virtual constructo...): Compile-time syntax error.
•
Option C (A class can have both virtual constru...): False.
•
Option D (Neither constructors nor destructors ...): False; virtual destructors are standard practice.
Reference: Mock Test 04NEC Licensure Syllabus