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

Difference between class and structure.

794


What are disadvantages of pointers?

662


Who invented turbo c++?

731


What is a class definition?

704


Explain the scope of resolution operator.

729






Are strings immutable in c++?

748


What is difference between class and function?

671


Differentiate between an inspector and a mutator ?

790


What are the effects after calling the delete this operator ?

667


Name the operators that cannot be overloaded in C++?

688


Why is c++ is better than c?

617


What is an adjust field format flag?

765


When do we run a shell in the unix system? How will you tell which shell you are running?

638


What are shallow and deep copies?

726


What is the benefit of c++?

695