// TreeNode.h
// Tree node header file for a general tree. This version is implemented with a 
// fixed size array. Using a linked list (from the linked list template toolkit)
// will result in amore elegant implementation. Be sure to add the '#include "link2.h"'
// preprocessor directive in this file.

#ifndef TREE_NODE
#define TREE_NODE

#include <iostream.h>
#include <stdlib.h>                                            // For definition of "NULL"

// Global constants:
const int giMaxChildren = 100;

class TreeNode
{
public:

  TreeNode();                                                  // Default constructor.
  TreeNode(int data);                                          // Data constructor.

  // Mutators:
  void addChild(TreeNode* tn);

  // Accessors:
  int getData();
  TreeNode* getChild(int i);
  TreeNode* findChild(int data);

private:

  int _data;                                                   // Integer data for demonstration,
                                                               // a template version will be more useful.
  int _numChildren;                                            // Number of children for this node.
  TreeNode** _children;                                      // Array of TreeNode pointers.
};

#endif
