Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Either clients should be able to delete polymorphically using a pointer to Base, or they shouldn’t. Each alternative implies a specific design:
Example 1: Base classes with polymorphic deletion. If polymorphic deletion should be allowed, the destructor must be public (else calling code can’t call it) and it must be virtual (else calling it results in undefined behavior).
Example 2: Base classes without polymorphic deletion. If polymorphic deletion shouldn’t be allowed, the destructor must be nonpublic (so that calling code can’t call it) and should be nonvirtual (because it needn’t be virtual).