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 / bala preethi

Since OOPS basics says always base class object to be
created and than its derivatives. So just consider the case
where we try to create object of derived class with virtual
contructor since pointer points to derived type object it
fetches derived constructor directly, without its base
class object constructed( instantiated )...
So Constructor cannot be made virtual bt when comes to case
of Destructor object destuction process must be reverse...
So we must make destructor as virtual.
This applies only when we going for Dynamic Memory
Allocation...

If, on the other hand, you were to have a pointer to object
A and assign it a dynamic object B, when you destroy it,
only object A's destructor is called and object B part of
the object is never destroyed. Virtual destructors are used
to solve this problem and destroy the objects in the right
order.

Is This Answer Correct ?    47 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

State what is encapsulation and friend function?

1266


Why do we use oops?

1018


Which language is not a true object oriented programming language?

1135


Write a program to sort the number with different sorts in one program ??

2374


What is multilevel inheritance in oop?

1039


What is polymorphism oop?

1065


What is and I oop mean?

1207


Why do we need oop?

1200


write a program to find 2^n+1 ?

2072


Why is oop useful?

1107


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

4747


What is the purpose of polymorphism?

1126


Why is abstraction used?

1093


What is class and object with example?

1132


What is constructor overloading in oop?

1137