n classic object-oriented design
, a base class defines an interface in the form of public virtual member functions. A derived class may either override these functions or use them as-is. Often, this "all or nothing" policy is too coarse. What you really need is a more flexible design that allows a subclass to customize the functionality of a base class's service without overriding it entirely. This article shows how to use the Template design pattern
to achieve such flexibility.
How can a subclass redefine certain steps of an algorithm without changing the algorithm's structure?
Use the Template design pattern.