#ifndef BiTree_H
#define BiTree_H
struct BiNode
{
char data;
BiNode*lichild,*rchild;
}
class BiTree
{
public:
BiTree(){root=Creat(root);}
~BiTree(){Release(root);}
void PreOrder(){PreOrder(root);}
void InOrder(){InOrder(root);}
void PostOrder(){PostOrder(root);}
private:
BiNode*root;
BiNode*Creat(BiNode*bt);
void Release(BiNode*bt);
void PreOrder(BiNode*bt);
void InOrder(BiNode*bt);
void PostOrder(BiNode*bt);
};
#endif
#include<iostream>//引入输入输出流
using namespace std;
#include "BiTree.h"//引入类BiTree的声明
BiNode*BiTree::Creat(BiNode*bt)//类BiTree的成员函数定义
{
char ch;
cout<<"请输入创建一棵二叉树的节点数据"<<endl;
cin>>ch;
if(ch=='#')return NULL;
else{<pre class="html" name="code">#include<iostream>
using namespace std;
#include "BiTree.h"
int main()
{
BiTree T;
cout<<"--------前序遍历-------"<<endl;
T.PreOrder();
cout<<endl;
cout<<"--------中序遍历-------"<<endl;
T.InOrder();
cout<<endl;
cout<<"------后序遍历-------"<<endl;
T.PostOrder();
cout<<endl;
return 0;
}