Can a class have virtual constructor??
If yes, why it is required?
No, how would it work? All constructors in the hierarchy have to be called when you derive child classes from base classes. Making a constructor virtual would imply otherwise.
Something that may be described as having virtual constructor like behaviour, is when you use the factory pattern. Imagine this scenario:
class AnimalFactory
{
virtual Animal CreateAnimal( return new Animal("Cow"); );
}
The default behaviour of this factory is to create cows. But if we create a derived class:
class DogFactory : AnimnalFactory
{
override Animal CreateAnimal( return new Animal("Dog"); );
}
We are now creating dogs. Of course this is not a true virtual constructor (which is impossible), this is virtual construction.