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

Virtual Constuctor

Status
Not open for further replies.

moonoo

Programmer
May 17, 2000
62
0
0
US
Hi<br>&nbsp;&nbsp;Why I can't have my contructor as virtual if I am<br>deriving any classes from it ? If I want my constructor<br>to be virtual how to achieve the objective<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Regards<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Moonoo
 
Hi,<br><br>The construcor is always virtual ! I mean it is more than virtual.<br><br>If you have classes like<br><br>class A&nbsp;&nbsp;<br>and <br>class B : public A<br><br>Then Any construcor of class B will call the A(void) Constructor of class A, unless you make it call some other Constructor.<br><br>The best you can do here is do not define A() in class A. <br>So B(xyz pqr) will not call anything from class A !! <br><br>you may want to have a look at this...<br><A HREF=" TARGET="_new"> <p> <br><a href=mailto: > </a><br><a href= site for Debugging !</a><br>Try this site for debugging...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top