// Node.h // word consists of a generic node with 2 pointers // data is of type T // left is pointing to left child of Node // right is pointing to right child of Node // is templatized on Pair // this is the base class for ModNode #ifndef NODE_CLASS #define NODE_CLASS #include "Pair.h" template class Node { private: T word; Node *left; Node *right; public: // default constructor // initializes all data members to default values Node(); // constructor with Pair p // other data members are set to default values Node(T p); // constructor with data members set to // p, l and r, respectively Node(T p, Node *l, Node *r); // destructor virtual ~Node(); // accessor for word (Pair) // returns the word (Pair) // need to define it this way in order to use iterators const T & getWord() const; // accessor for pair // non-const version of getWord() T & getWord(); // returns reference to a pointer to the node "left" points to Node *& getLeft(); // returns reference to a pointer to the node "right" points to Node *& getRight(); // mutator - changes value of left to x void setLeft(Node * x); // mutator - changes value of right to y void setRight(Node * y); // mutator - changes the value of word void setWord(T p); // for the purpose of testing Node class // writes the contents of a single Node // writes the following: text = codeword // writes the following: code = numbers // where "codeword" and "numbers" are replaced // by actual values in the node // calls writer methods from Pair.cpp void writer(); private: // you may put any other private methods here }; #endif // NODE_CLASS