You need to make A
polymorphic, which you can do by adding a virtual
destructor or any virtual function:
struct A {
virtual ~A() = default;
};
or, before C++11,
struct A {
virtual ~A() {}
};
Note that a polymorphic type should have a virtual destructor anyway, if you intend to safely call delete on instances of a derived type via a pointer to the base.