In my application I used to have a unique_ptr<parent> _member
as a member of a custom class. The code worked fine. However when I recently tried to create another class that inherit from the parent
class, and initialize _member
using _member = unique_ptr<child>(new child())
in the constructor, I realize that when the custom class got destroyed, the destructor of _member
only calls the parent destructor but now the child destructor.
This behavior makes sense to me. Because afterall _member
is of type unique_ptr<parent>
. However I'm wondering what are the options for me to call the child destructor given only _member
.