#ifndef bitree1_h
#define bitree1_h
typedef char ElemType;
struct BiNode
{
ElemType data;
BiNode* lchild;
BiNode* rchild;
};
class BiTree
{
public:
BiTree(BiNode* root);
~BiTree();
void Preorder(BiNode *root);
void Postorder(BiNode *root);
private:
BiNode *root;
void Creat(BiNode *root);
void Release(BiNode *root);
};
#endif
#include "bitree.h"
#include"iostream.h"
//二叉树构造 函数的调用 函数
void BiTree::Creat(BiNode* root)
{
ElemType ch;
cout<<"please enter the data:"<<endl;
cin>>ch;
if(ch=='#') root=NULL;
else
{
root=new BiNode;
root->data=ch;
Creat(root->lchild);
Creat(root->rchild);
}
return;
}
//二叉树的析构函数的调用函数
void BiTree::Release(BiNode* root)
{
if(root!=NULL)
{
Release(root->lchild);
Release(root->rchild);
delete root;
}
}
//二叉树的构造函数
BiTree::BiTree(BiNode* root)
{
Creat(root);
}
//二叉树的析构函数
BiTree::~BiTree()
{
Release(root);
}
#include <iostream.h>
#include "bitree.h"
int main()
{
BiNode* room=0;
BiTree mytree(room);
return 0;
}
Linking...
ceshi.obj : error LNK2001: unresolved external symbol "public: __thiscall BiTree::~BiTree(void)" (??1BiTree@@QAE@XZ)
ceshi.obj : error LNK2001: unresolved external symbol "public: __thiscall BiTree::BiTree(struct BiNode *)" (??0BiTree@@QAE@PAUBiNode@@@Z)
Debug/ceshi.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.