#ifndef __tree__ #define __tree__ // This file gives specifications for the TREE and FOREST classes. // It assumes that trees are ordered trees with at most 10 children. // It assumes that forests contain at most 10 trees. #include #include // Public member functions for the TREE class include: // A constructor that takes a string and returns a tree with // no children and with the string as its data element. // A function GET_DATA that returns a pointer // to the data. // A function GET_CHILD that takes an integer I and // returns a pointer to the Ith child of the tree. // A procedure SET_CHILD that takes a TREE pointers and an integer I // and makes the tree the Ith child. // Two TRAVERSE procedures, each printing an indented // representation of a preorder traversal of the tree. // The second procedure writes this traversal to a specified stream // The first procedure writes to standard output, and takes no // argument. const MAXTSIZE = 10; // maximum number of children per tree class tree { public: tree (char *d); char *get_data(void); tree *get_child(int i); void set_child(tree *c, int i); void traverse(void); void traverse(ostream &os); private: // ?? }; // Public member functions for the FOREST class include: // A constructor that creates an empty FOREST // A procedure that, given a pointer to a TREE, adds it to the forest // Two procedures that traverse forests by traversing each tree in // the forest. The second takes a stream reference as argument; // the result of the traversal is to be written to this stream. // The first prints to standard output. const MAXFSIZE = 10; // maximum number of trees per forest class forest { public: forest(void); void add_to_forest(tree *); void traverse(void); void traverse(ostream &os); private: // ?? }; #endif