Search This Blog

Tuesday, February 19, 2013

Why a constructor cannot be declared as virtual?

A constructor cannot be virtual because at the time when the constructor is invoked the virtual table would not be available in the memory. Hence we cannot have a virtual constructor.

We can't override a constructor. When any method is declared as virtual it should be overridden in its derived class. Since constructor is used for initializing the variables and if declare a constructor as virtual it can’t be overridden.

No comments:

Post a Comment