Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

In c++ there is only virtual destructors, no constructors. Why?

Answer Posted / subhashish sen

Constructor can not be virtual...The main reason is when we
have a virtual function in a class the VTABLE for that
function will be created..which contains the address of the
virtual function...means for each class which contains a
virtual function a VTABLE will be created and constructor is
an entity which initializes this VTABLE.So if you declare
constructor as virtual who will initialize VTABLE for it.

Destructors can be virtual because virtual destructor
ensures proper calling order of all destructors in a class
hierarchy.

If you need further clarification reply me....

Is This Answer Correct ?    28 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is overriding vs overloading?

1111


what is the sylabus for priliminaries?

2227


What is the difference between abstraction and polymorphism?

1158


What causes polymorphism?

1187


Why interface is used?

1070


Where is pseudocode used?

1170


What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?

2596


What is the difference between static polymorphism and dynamic polymorphism?

1138


Is oop better than procedural?

1089


Can a destructor be called directly?

1137


hi all..i want to know oops concepts clearly can any1 explain??

2178


What is abstraction in oop with example?

1192


Can you explain polymorphism?

1159


Why is encapsulation used?

1056


What does no cap mean?

1118