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

How do you declare a set in c++?

0 Answers  


when can we use copy constructor?

6 Answers   HP,


Why c++ is the best language?

0 Answers  


what is the size of a class which contains no member variables but has two objects??? is it 1 or 2??

4 Answers  


How a macro differs from a template?

0 Answers  






Is c++ a good first language to learn?

0 Answers  


What is the Maximum Size that an Array can hold?

55 Answers   Adobe, FutureSoft, HCL, Infosys, Satyam, TCS, Wipro,


What is a class template in c++?

0 Answers  


Why isn't sizeof for a struct equal to the sum of sizeof of each member?

0 Answers  


Explain the use of this pointer?

0 Answers  


If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?

0 Answers  


Hi i need to Acess a variable "int Intval" in the below mentioned code .How to Access it guys i am waiting for your reply

3 Answers  


Categories