c++实验----------二叉树代码
#include using namespace std; template class BinaryTree; template class BinTreeNode { friend class BinaryTree; private: BinTreeNode *leftChild,*rightChild; Type data; public: BinTreeNode():leftChild(NULL),rightChild(NULL){} BinTreeNode(Type d,BinTreeNode *lp=NULL,BinTreeNode *rp=NULL):data(d),leftChild(lp),rightChild(rp){} Type GetData() {return data;} BinTreeNode *GetLeftChild() const {return leftCh ild;} BinTreeNode *GetRightChild() const {return rightChild;} void SetData(const Type &d) {data=d;} void SetLeftChild(BinTreeNode *p) {leftChild=p;} void SetRightChild(BinTreeNode *p) {rightChild=p;}
用户评论