Why is it so that we can have virtual constructors but we
cannot have virtual destructors?

Answers were Sorted based on User's Feedback



Why is it so that we can have virtual constructors but we cannot have virtual destructors?..

Answer / rdl

We can have Virtual Destructor. We cannot have virtual
constructor, becoz, if the constructor is virtual, in
polymorphism, there may be a chance for the base class
constructor not to get executed. so the entire class will
not be available.

Is This Answer Correct ?    11 Yes 0 No

Why is it so that we can have virtual constructors but we cannot have virtual destructors?..

Answer / sachinmundhra

vptr gets initialize in constructor. So in that case we
cannot have virtual constructor.

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More OOPS Interview Questions

What is encapsulation with real life example?

0 Answers  


how do you handle yourself when you feel the wald is aganist you

2 Answers  


Can we define a class within the interface?

0 Answers  


Differences between inline functions and non-inline functions?

4 Answers   Ness Technologies,


Please send ford technologies placement paper 2 my mail id

0 Answers  


what is a virtual class?

5 Answers   Cap Gemini, IBM, Infosys, Trinity Technologies,


What are classes oop?

0 Answers  


What is the difference between declaration and definition?

20 Answers   IBS,


Is react oop?

0 Answers  


Base class has two public data members. How can i derive a new class with one datamember as public and another data member as private?.

2 Answers  


1. Define a class.

6 Answers  


What is class and object with example?

0 Answers  


Categories