What is virtual destructors? Why they are used?



What is virtual destructors? Why they are used?..

Answer / hrpynux@gmail.com

Virtual destructors in C++ are used to avoid memory leaks especially when your class contains unmanaged code, i.e., contains pointers or object handles to files, databases or other external objects. A destructor can be virtual. ... Now, suppose you create an instance of the Derived class using a Base class pointer.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is namespace & why it is used in c++?

0 Answers  


write a corrected statement in c++ so that the statement will work properly. x = y = z + 3a;

0 Answers  


List down the guideline that should be followed while using friend function.

0 Answers  


whats the size of class EXP on 32 bit processor? class EXP { char c1; char c2; int i1; int i2; char *ptr; static int mem; };

5 Answers   Huawei,


What does flush do?

0 Answers  






What is Pure Virtual Function? Why and when it is used ?

10 Answers   Lucent, Sona,


What is the latest c++ version?

0 Answers  


Program to check whether a word is a sub-string or not of a string typed

0 Answers  


What is a smart pointer?

1 Answers  


Is c++ an oop?

0 Answers  


What is abstraction with real time example?

0 Answers  


Is map thread safe c++?

0 Answers  


Categories