///
// //
// 二叉树数据结构 BinTree.h //
// //
//
#include<iostream.h>
template<class Type>class BinTree;
template<class Type>
class TreeNode
{
protected:
friend class BinTree<Type>;
TreeNode():lchild(NULL),rchild(NULL){}
Type data;
TreeNode *lchild; //左,右子树
TreeNode *rchild;
};
template<class Type>
class BinTree
{
friend void BinTree_PRE(BinTree<Type>& BinTreeOPP); //友元函数
friend void BinTree_INO(BinTree<Type>& BinTreeOPP);
friend void BinTree_POS(BinTree<Type>& BinTreeOPP);
friend void BinTree_Destroy(BinTree<Type>& BinTreeOPP);
public:
BinTree():root(NULL){}
void CreatTree(); //创建二叉树,主过程
void CreatTree(TreeNode<Type>* child,int k); //子过程 <
// //
// 二叉树数据结构 BinTree.h //
// //
//
#include<iostream.h>
template<class Type>class BinTree;
template<class Type>
class TreeNode
{
protected:
friend class BinTree<Type>;
TreeNode():lchild(NULL),rchild(NULL){}
Type data;
TreeNode *lchild; //左,右子树
TreeNode *rchild;
};
template<class Type>
class BinTree
{
friend void BinTree_PRE(BinTree<Type>& BinTreeOPP); //友元函数
friend void BinTree_INO(BinTree<Type>& BinTreeOPP);
friend void BinTree_POS(BinTree<Type>& BinTreeOPP);
friend void BinTree_Destroy(BinTree<Type>& BinTreeOPP);
public:
BinTree():root(NULL){}
void CreatTree(); //创建二叉树,主过程
void CreatTree(TreeNode<Type>* child,int k); //子过程 <