How do you know that your class needs a virtual destructor?

Answer Posted / guest

If your class has at least one virtual function, you should
make a destructor for this class virtual. This will allow
you to delete a dynamic object through a baller to a base
class object. If the destructor is non-virtual, then wrong
destructor will be invoked during deletion of the dynamic
object.

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does class accomplish data hiding in c++?

662


What is time_t c++?

615


Do the parentheses after the type name make a difference with new?

655


What is doubly linked list in c++?

641


What is the use of class in c++?

572






What is #include iomanip?

554


What is meant by a delegate?

612


what are function pointers?

582


What is function prototyping?

622


What is virtual destructor? What is its use?

579


What is the size of a vector?

586


What is pure virtual function?

633


Explain rethrowing exceptions with an example?

612


Write about the local class and mention its use?

617


What is the disadvantage of using a macro?

595