初学数据结构 二叉树的问题
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define OK 1
#define OVERFLOW -2
typedef int Status;
typedef char TElemType;
typedef struct BiTNode{
TElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode, * BiTree;
Status CreateBiTree(BiTree &T){
TElemType ch;
scanf( "%c ",&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;
}
void main()
{
CreateBiTree(BiTree &T);
}
报错如下:
--------------------Configuration: compress - Win32 Debug--------------------
Compiling...
compress.cpp
E:\数据结构\树\compress.cpp(35) : error C2065: 'T ' : undeclared identifier
E:\数据结构\树\compress.cpp(35) : error C2275: 'BiTree ' : illegal use of this type as an expression
E:\数据结构\树\compress.cpp(15) : see declaration of 'BiTree '
Error executing cl.exe.
compress.exe - 2 error(s), 0 warning(s)
二叉树学习中 请多执教!
[解决办法]
void main()
{
CreateBiTree(BiTree &T); //哪有这么调用的
}