// Simple binary tree node implementation template class BinNodePtr : public BinNode { private: Elem it; // The node's value BinNodePtr* lc; // Pointer to left child BinNodePtr* rc; // Pointer to right child public: // Two constructors -- with and without initial values BinNodePtr() { lc = rc = NULL; } BinNodePtr(Elem e, BinNodePtr* l =NULL, BinNodePtr* r =NULL) { it = e; lc = l; rc = r; } ~BinNodePtr() {} // Destructor // Functions to set and return the value Elem& val() { return it; } void setVal(const Elem& e) { it = e; } // Functions to set and return the children inline BinNode* left() const { return lc; } void setLeft(BinNode* b) { lc = (BinNodePtr*)b; } inline BinNode* right() const { return rc; } void setRight(BinNode* b) { rc = (BinNodePtr*)b; } // Return true if its a leaf, false otherwise bool isLeaf() { return (lc == NULL) && (rc == NULL); } };