10 Years
Discussion Span
Last Post by Ancient Dragon

I think the only way to create a "virtual constructor" is to make a virtual method that returns the object inquestion, where derived classes return a copy of their type instead of the base classes return implementation.

By casting a derived type to a base type and invoking the virtual constructor method, you're constructing an object virtually, therefore it's safe to say it is a "virtual constructor".


constructor can't be defined as virtual bcuz if a class contains virtual function then the associate vtable must be initiated by the constructor of that class.if we define constructor as virtual then it creates a problem that who initiates that vtable.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.