Explain virtual destructor?



Explain virtual destructor?..

Answer / Navneet Sahu

A virtual destructor in C++ ensures that the correct destructor is called when a derived class object is destroyed, even if it's done through a base class pointer. This is important because the destructors of base and derived classes may have dependencies on each other. By declaring the destructor as virtual, the appropriate destructor for the derived class will be called during destruction.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Write is a binary search tree? Write an algo and tell complexity?

1 Answers   Axtria,


How should a contructor handle a failure?

1 Answers  


Can circle be called an ellipse?

1 Answers  


why v use c++ even we have microprocessor

2 Answers   CybAge,


State the difference between delete and delete[].

1 Answers  


What is lvalue?

1 Answers  


State two differences between C and C++.

1 Answers   Hexaware,


I want to write a C++ language program that: 1. Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. The program should work for squares of all side sizes between 1 and 20.

1 Answers  


founder of c++

7 Answers   Microtek, TCS, TeleCommand,


Which format specifier is used for printing a pointer value?

1 Answers  


What is one dimensional array in c++?

1 Answers  


What is the best ide for c++?

1 Answers  


Categories