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 microsoft c++ redistributable?

0 Answers  


Define a pointer to a data member of the type pointer to pointer?

0 Answers  


What is pure virtual function?

0 Answers  


How long will it take to learn programming?

0 Answers  


How to declare a function pointer?

0 Answers  






Can you explicitly call a destructor on a local variable?

0 Answers  


What is constructor in C++?

0 Answers  


Will this c++ program execute or not?

0 Answers  


How can you create a virtual copy constructor?

0 Answers  


Can class objects be passed as function arguments?

0 Answers   HCL,


How would perform Pattern Matching in C++?

0 Answers   Genpact,


What is ostream in c++?

0 Answers  


Categories