The solution to GotW #5 is now available:
GotW #5 Solution: Overriding Virtual Functions (updated for C ++11/14)
by Herb Sutter
From the article:
Exactly one of the following can be true for a polymorphic type:
- Either destruction via a pointer to base is allowed, in which case the function has to be
public
and had better bevirtual
;- or else it isn’t, in which case the function has to be
protected
(private
is not allowed because the derived destructor must be able to invoke the base destructor) and would naturally also be nonvirtual (when the derived destructor invokes the base destructor, it does so nonvirtually whether declaredvirtual
or not).
Add a Comment
Comments are closed.