-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXompTree.h
More file actions
59 lines (51 loc) · 1.11 KB
/
XompTree.h
File metadata and controls
59 lines (51 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//////////////////////////////////////////////////////
// File named 'XompTree.h' is the header file for demo
// of binary tree graph, used to simulate user inputs.
//////////////////////////////////////////////////////
// helper function added to standard class
class fileStream: public ifstream
{
public:
void rewind();
};
// abstract base class to compose objects into a tree structure
class node
{
public:
static int theDepth;
static int nodeCount;
static int maxDepth;
virtual ~node();
// pure virtual functions
virtual void populate() = 0;
virtual void express(ostream &) = 0;
};
// composite class, may have child nodes
class brnch: public node
{
private:
char pre[32];
char inter[32];
char post[32];
list<node *> the_list;
public:
static fileStream brnchFile;
~brnch();
void populate();
void express(ostream &);
};
// component class, no child nodes
class leaf: public node
{
private:
char the_str[32];
int myDepth;
public:
static fileStream leafFile;
leaf();
~leaf();
void populate();
void express(ostream &);
};
// insertion opeartor for node class
ostream &operator<<(ostream &, node *);