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
Where You Can Use Interface in your Project
write a program to find 2 power of a 5digit number with out using big int and exponent ?
What is pure oop?
what is different between oops and c++
I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...
What is static modifier?
What is solid in oops?
When not to use object oriented programming?
What is data binding in oops?
Templates mean
What is abstraction example?
How do you explain polymorphism?
How do you achieve runtime polymorphism?
What are the types of abstraction?
Can an interface inherit a class?