In software engineering, the template method pattern is a design pattern.
A template method defines the skeleton of an algorithm in terms of abstract operations which subclasses override to provide concrete behaviour.
For example, given a skeleton for common operations on data structures, there may be a few common operations and some specific to the data structure. The data structure template class can provide a template for each newly added data structure class.
class CDatastructure_Template { //Common operations: Algorithm Template void virtual CleanAll()=0; void virtual AddNode(Node *node)=0; void virtual DeleteNode(Node *node)=0; long virtual GetNumElements()=0; Node* virtual GetTopNode()=0; Node* virtual GetNextNode(Node *CurrentNode)=0; }; class CLinkList_ConcTemplate:public Datastructure_Template; class CQueue_ConcTemplate:public Datastructure_Template; class CArray_ConcTemplate:public Datastructure_Template; class CTree_ConcTemplate:public Datastructure_Template;
New data structure class can be derived from the CLinkList_ConcTemplate, with operations modified as necessary.