+ 3
Someone explain to me why you need a virtual destructor? (In c++)
5 Antworten
+ 4
here you have the example, comments are in the code guys.
https://code.sololearn.com/cgrIXlszu299/#cpp
+ 3
because if you create an virtual method which can be overwritten in an inherited class (it can allocate extra memory for example) you need to give a chance to destroy it by appropriate way (it can destroy this extra memory which is unreachable for parent destructor).
+ 2
Highman can you give an example?
+ 2
Thank you. Evrything became clear.
0
Do you know why you need virtual functions in general?