In case of an inheritance chain, make a destructor virtual in order to use correct object destructors. More information can be found here