The C++ Standard has this to say about delete
(section 5.3.5p10):
Access and ambiguity control are done for both the deallocation function and the destructor (12.4, 12.5).
Therefore, only code that has access to the destructor is able to use delete
. Since the destructor is protected
, that means that no one can call delete
on a pointer of type Base*
. Only subclasses can use the destructor at all (and the only thing that will is the subclass's own destructor, as part of the subobject destruction process).
Of course, the subclass should make its own destructor public
, allowing you to delete objects through the subclass type (assuming that is the correct actual type).
NOTE: Actually, other members of Base
can do delete (Base*)p;
since they have access. But C++ assumes that someone using this construct will not be doing that -- C++ access control only provides guidance to code outside your class.