Interview Question: why we need a virtual destructor in C++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Interview Question: why we need a virtual destructor in C++?

Virtual functions aren't cheap, but there is a case when it is necessary for a class destructor to be virtual. Why?

9th Apr 2018, 3:20 PM
vardanator
vardanator - avatar
4 Answers
+ 5
Hi here is the link to previous discussion about this topic. https://www.sololearn.com/Discuss/958953/?ref=app
9th Apr 2018, 3:27 PM
Highman
Highman - avatar
+ 5
Thanks Highman !
9th Apr 2018, 3:53 PM
vardanator
vardanator - avatar
+ 2
you are welcome;)
9th Apr 2018, 3:55 PM
Highman
Highman - avatar
+ 1
to have more memory when we finish the programm
4th May 2018, 4:50 PM
نيرمين آل حمد
نيرمين آل حمد - avatar