Jump to content

Talk:Template method pattern

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 84.58.125.100 (talk) at 20:47, 24 May 2005 (replaced example). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

I removed the following example and replaced it with mine, which I translated from the french version. Feel free to revert if you have reasons to do so. If not, feel free to correct my english :)

<removed stuff>

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.

</removed stuff>