Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can there be virtual constructor

Status
Not open for further replies.

tekdev

Programmer
Feb 12, 2003
3
IN
Hello

Can Constructor be a virtual.
 
I would think so but there is no reason for it. Virtual is used in inheritance. You can call the parent constructor upon creation. If you need access to private members of the parent then they should not be private but protected. Also, the child class would need to redefine the parent constructor.

Matt
 
No, constructors can't be virtual. If you require functionality analogous to virtual constructors, look up the Abstract Factory, Builder, or Factory Method design patterns and see if they provide a solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top