24 Nov 2019

  • November 24, 2019
  • Amitraj
Why A Constructor can not be Virtual

"A constructor can not be virtual". There are some valid reasons that justify this statement.

-> First, to create an object the constructor of the object class must be of the same type as the class. But, this is not possible with a virtually implemented constructor.

-> Second, at the time of calling the constructor, the virtual table would not have been created to resolve any virtual function calls.

-> Thus, a virtual constructor itself would not have anywhere to look up to. As a result, it is not possible to declare a constructor as virtual.

Translate

Popular Posts