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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Virtual Constructor

Status
Not open for further replies.

moonoo

Programmer
May 17, 2000
62
US
Hi<br>&nbsp;Why can't a constuctor be virtual while a destructor<br>can be.<br>&nbsp;&nbsp;&nbsp;Regards<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;moonoo
 
because the Contructor of a class is always run, when you create a new object, and you call it, it first runs the Base Constructor, then it runs the Inherited constructor, where as a deconstructor, does not always need to run. Thats what I think. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Hello,<br><br>In the book &quot;The C++ Programming Language&quot; (Stroustrup) there is an explanation on how to reach the same behavior as a virtual constructor.<br><br>All the Best,<br><br>Ami Tavory<br><br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top