以下是二叉树结构体的C++模板类头文件源代码:
//binarytree.h #ifndef BINARYTREE_H #define BINARYTREE_H #includetemplatestruct BinNode{ Type data; BinNode* left; BinNode* right; }; templateclass BinTree { private: BinNode* root; public: BinTree(); ~BinTree(); void ReleaseBinNode(BinNode*); bool IsEmpty(); void AddNode(Type); void PreOrderTraversal(BinNode*); void PreOrderTraversal(){PreOrderTraversal(root);} void InOrderTraversal(BinNode*); void InOrderTraversal(){InOrderTraversal(root);} void PostOrderTraversal(BinNode*); void PostOrderTraversal(){PostOrderTraversal(root);} void NonRecursionTraversal(); void NonRecursionPostTraversal(); void LevelOrderTraversal(); void PrintLeaves(); void PrintLeaves(BinNode*); int GetHeight(); int GetHeight(BinNode*); void Delete(Type); void Delete(BinNode* ,Type); BinNode* FindMin(BinNode*); BinNode* GetParentNode(BinNode*); }; templateBinTree::BinTree() { root=NULL; } templateBinTree::~BinTree() { ReleaseBinNode(root); } templatevoid BinTree::ReleaseBinNode(BinNode* t