各位大哥大姐门帮忙查以下错啊:
头文件:
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef char TElemType;
typedef int status;
typedef struct BiTNode
{
TElemType data;
struct BiTNode * lchild,* rchild;
}BiTNode,*BiTree;
status CreateBiTree(BiTree &T);
status PreOrderTraverse(BiTree T,status(*visit)(TElemType e));
status InOrderTraverse(BitTree T,status (*visit)(TElemType e));
#include<iostream.h>
#include "la2.h"
#include<stdlib.h>
status CreateBiTree(BiTree &T)
{ char ch;
cin>>ch;
if(ch=='$')
T=NULL;
else
{
if(!(T=(BiTNode *)malloc(sizeof(BiTNode))))
exit(OVERFLOW);
T->data=ch;
CreateBiTree(T->lchild);
CreateBiTree(T->rchild);
}
return OK;
}
status PrintElement(TElemType e)
{ cout<<e<<"\t";
return OK;
}
status PreOrderTraverse(BiTree T,status (* visit)(TElemType e))
{ if(T){
if(visit(T->data))
if(PreOrderTraverse(T->lchild,visit))
if(PreOrderTraverse(T->rchild,visit))
return OK;
return ERROR;
}
return OK;
}//PreOrderTraverse;
status InOrderTraverse(BitTree T,status (* visit)(TElemType e))
{
if(T){
if(InOrderTraverse(T->lchild,visit))
if(visit(T->data))
if(InOrderTraverse(T->rchild,visit))
return OK;
return ERROR;
}return OK;
}
void main()
{ BiTree T1;
cout<<"请输入二叉树先序遍历"<<endl;
CreateBiTree(T1);
cout<<"please output"<<endl;
PreOrderTraverse(T1,PrintElement);
cout<<endl;
cout<<"please output"<<endl;
InOrderTraverse(T1,PrintElement);
cout<<endl;
}
f:\visual c++\8\la2.h(16) : error C2065: 'BitTree' : undeclared identifier
f:\visual c++\8\la2.h(16) : error C2146: syntax error : missing ')' before identifier 'T'
f:\visual c++\8\la2.h(16) : error C2059: syntax error : ')'
f:\visual c++\8\la1.cpp(35) : error C2146: syntax error : missing ')' before identifier 'T'
f:\visual c++\8\la1.cpp(35) : error C2086: 'InOrderTraverse' : redefinition
f:\visual c++\8\la1.cpp(35) : error C2059: syntax error : ')'
f:\visual c++\8\la1.cpp(36) : error C2143: syntax error : missing ';' before '{'
f:\visual c++\8\la1.cpp(36) : error C2447: missing function header (old-style formal list?)
f:\visual c++\8\la1.cpp(57) : error C2064: term does not evaluate to a function
执行 cl.exe 时出错.