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.