home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / SAMPLES / COMPILER / SAMPLE06 / READ.ME < prev    next >
Text File  |  1993-05-07  |  2KB  |  67 lines

  1. This sample shows the progression going from basic classes to templates.
  2.  
  3. A container (an n-ary tree) and data (the TreeData class) are defined
  4. separately, and then the data is introduced into the container. There
  5. are two ways to accomplish this:
  6.  
  7. 1- The TreeData class is 'joined' in the Tree classes by the DataInTree class.
  8.    DataInTree is derived from TreeNode, and has a data member that is a
  9.    TreeData object.
  10.  
  11. 2- Define an n-ary tree of TreeData. This is done using templates.
  12.  
  13. The files for the sample program are listed below.
  14.  
  15. First, there are the classes for the container, which is an n-ary tree.
  16. These are the TreeLink and the TreeNode classes.
  17.  
  18. TREELINK.CPP      Encapsulates the links to the immediate neighbours
  19. TREELINK.HPP
  20.  
  21. TREENODE.CPP      This class encapulates the behaviour of a data structure
  22. TREENODE.HPP         known as an n-ary Tree.
  23.  
  24. Then there is the TreeData class, which encapulates the data part of
  25. a TreeNode. This 'encapsulation' is necessary because the 'data' portion
  26. could really be 'data' but it could also be another TreeNode.
  27.  
  28. TREEDATA.CPP      Encapsulates the data part of a TreeNode
  29. TREEDATA.HPP
  30.  
  31. Finally, data is introduced into the container.
  32.  
  33. DATNTREE.CPP      The DataInTree class joins the TreeData class with the Tree
  34. DATNTREE.HPP         classes
  35.  
  36. The possibility of how to make the data generic is introduced. Here the
  37. role of the DataInTree class is now taken over by the GenTree class. It
  38. is not so generic just yet.
  39.  
  40. GENTREE.C         Implementation file for the GenTree template. It has .C
  41. GENTREE.HPP          file extension as required by the compiler support
  42.                      for automatic template creation with the /Ft option.
  43.  
  44. There are two implementations of an application that stores author names
  45. and book titles in the container:
  46.  
  47. AUTHORS1.CPP      Uses the DataInTree class
  48. AUTHORS2.CPP      Uses the GenTree template
  49.  
  50. To build the sample program, use the supplied make files:
  51.  
  52. MAKE06S           Builds AUTHORS1.EXE and AUTHORS2.EXE. The compiler libraries
  53.                   are linked statically.
  54.  
  55. MAKE06D           Builds AUTHORS1.EXE and AUTHORS2.EXE. The compiler libraries
  56.                   are linked dynamically.
  57.  
  58. For example:
  59.  
  60.     nmake all -f make06d
  61.  
  62. To clean up after the sample program has been built and run, type the following
  63. command:
  64.  
  65.     nmake clean -f make06d
  66.  
  67.