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 >
Wrap
Text File
|
1993-05-07
|
2KB
|
67 lines
This sample shows the progression going from basic classes to templates.
A container (an n-ary tree) and data (the TreeData class) are defined
separately, and then the data is introduced into the container. There
are two ways to accomplish this:
1- The TreeData class is 'joined' in the Tree classes by the DataInTree class.
DataInTree is derived from TreeNode, and has a data member that is a
TreeData object.
2- Define an n-ary tree of TreeData. This is done using templates.
The files for the sample program are listed below.
First, there are the classes for the container, which is an n-ary tree.
These are the TreeLink and the TreeNode classes.
TREELINK.CPP Encapsulates the links to the immediate neighbours
TREELINK.HPP
TREENODE.CPP This class encapulates the behaviour of a data structure
TREENODE.HPP known as an n-ary Tree.
Then there is the TreeData class, which encapulates the data part of
a TreeNode. This 'encapsulation' is necessary because the 'data' portion
could really be 'data' but it could also be another TreeNode.
TREEDATA.CPP Encapsulates the data part of a TreeNode
TREEDATA.HPP
Finally, data is introduced into the container.
DATNTREE.CPP The DataInTree class joins the TreeData class with the Tree
DATNTREE.HPP classes
The possibility of how to make the data generic is introduced. Here the
role of the DataInTree class is now taken over by the GenTree class. It
is not so generic just yet.
GENTREE.C Implementation file for the GenTree template. It has .C
GENTREE.HPP file extension as required by the compiler support
for automatic template creation with the /Ft option.
There are two implementations of an application that stores author names
and book titles in the container:
AUTHORS1.CPP Uses the DataInTree class
AUTHORS2.CPP Uses the GenTree template
To build the sample program, use the supplied make files:
MAKE06S Builds AUTHORS1.EXE and AUTHORS2.EXE. The compiler libraries
are linked statically.
MAKE06D Builds AUTHORS1.EXE and AUTHORS2.EXE. The compiler libraries
are linked dynamically.
For example:
nmake all -f make06d
To clean up after the sample program has been built and run, type the following
command:
nmake clean -f make06d