What is virtual destructors? Why they are used?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How a modifier is similar to mutator?

631


Define linked lists with the help of an example.

550


What do you mean by const correctness?

626


What is the difference between global int and static int declaration?

403


Which programming language's unsatisfactory performance led to the discovery of c++?

797






Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.

614


What is a lambda function c++?

549


What do you mean by vtable and vptr in c++?

619


total amount of milk produced each morning and then calculates and outputs the number of cartons needed for this milk , the cost of producing the milk and the profit from producing this milk.

2079


What is the use of default constructor?

568


Explain Text Manipulation Routines?

644


What is a terminating character in c++?

760


What is a multimap c++?

673


How can you quickly find the number of elements stored in a static array?

633


Is oops and c++ same?

576