Write about the use of the virtual destructor?



Write about the use of the virtual destructor?..

Answer / Vinod Kumar Maurya

A virtual destructor in C++ is used when dealing with polymorphic classes (base class and derived class). It ensures that the correct destructor is called for each object, regardless of how it was created or which specific type it actually is at runtime. This is crucial to prevent memory leaks or other undefined behavior.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Do we have to use initialization list in spite of the assignment in constructors?

1 Answers  


What is do..while loops structure?

1 Answers  


give me some class & objects examples?

1 Answers  


Can you think of a situation where your program would crash without reaching the breakball, which you set at the beginning of main()?

1 Answers  


Why seem interrupt handlers as member functions to be impossible?

1 Answers  


how to explain our contribution in the project?

1 Answers   Wipro, Yahoo,


What is the purpose of ios::basefield in the following statement?

1 Answers  


why v use c++ even we have microprocessor

2 Answers   CybAge,


Why should we use null or zero in a program?

1 Answers  


What is a Default constructor?

2 Answers  


Which one is a preferred language C or C++? Why?

1 Answers  


Can I learn c++ without learning c?

1 Answers  


Categories