Separating interfaces and implementations with the non-virtual interface idiom
Virtual functions provide specialization points for a class by allowing derived classes to modify implementations from a base class. When a derived class object is handled through a pointer or a reference to a base class, calls to overridden virtual functions end up invoking the overridden implementation from the derived class. On the other hand, a customization is an implementation detail, and a good design separates interfaces from implementation.
The non-virtual interface idiom, proposed by Herb Sutter in an article about virtuality in the C/C++ Users Journal, promotes the separation of concerns of interfaces and implementations by making (public) interfaces non-virtual and virtual functions private.
Public virtual interfaces prevent a class from enforcing pre- and post-conditions on its interface. Users expecting an instance of a base class do not have the guarantee that the expected behavior...