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 are the uses of C++

1 Answers  


polymorphism means?

6 Answers   BFL,


how to find the correct email address format by using the programe?

1 Answers   Accenture,


Can we create object of abstract class?

0 Answers  


How many human genes are polymorphic?

0 Answers  






Why do we use inheritance?

0 Answers  


create a class complex having real and imaginary part of a complex no. as a data member. overload the binary operators(+,- and *) to perform the operations on complex no. objects. overload binary operator using friend function.

2 Answers   CTS, Delhi University,


What is difference between inheritance and polymorphism?

0 Answers  


what is the drawback of classical methods in oops?

0 Answers  


What is and I oop mean?

0 Answers  


what is the virtual function overhead, and what is it used for ? i hope i can get and appropriate answers, thanks a lot....

6 Answers  


You attempt to query the data base with this command: SELECT name, salary FROM employee WHERE salary=(SELECT salary FROM employee WHERE last name='Wagner' OR dept no=233) Choose most appropriate option from the following: 1)Sub-queries are not allowed in the where clause. 2)a multiple row sub-query used with a single row comparison operator. 3)a single row query is used with a multiple row comparison operator.

10 Answers   Zycus Infotech,


Categories