If I'm correct, a default destructor is always implicitly declared, unless the user declares it. According to cppreference:
Deleting an object through pointer to base invokes undefined behavior unless the destructor in the base class is virtual
Now, consider this example:
struct B {};
struct D : B {};
Is the implicitly declared destructor B::~B()
virtual? If not, should I always declare a virtual destructor when using inheritance?
Aucun commentaire:
Enregistrer un commentaire