急!明天就要交作业了!
作业要求之一就是建立一棵二叉树。我的思路是依据广义表字符串S中建树。
但要编译时出现错误:
error C2440: '=' : cannot convert from 'struct BiTree *' to 'struct Bitree *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
I:\backup\DataStructure\BTree\a.cpp(40) : error C2440: '=' : cannot convert from 'struct BiTree *' to 'struct Bitree *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
源代码如下:
#include <stdio.h>
#include <stdlib.h>
typedef struct BiTree
{
char data;
struct Bitree *lchild;
struct Bitree *rchild;
}BitreeNode;
int CreateBiTree(BitreeNode ** BT)
{
char *s,ch;
int top = -1,i=0,key;
BitreeNode *node[10],*p;
*BT = NULL;
scanf("请输入树的广义表表达式,例如“A(B(D,E),C)@”:");
scanf("%s",s);
ch = s[i++];
while(ch !='@')
{
switch(ch)
{
case '(':node[++top] = p;key = 1;break;
case ')':top--;break;
case ',':key = 2;break;
default: p = new BitreeNode;
p->data = ch;
p->lchild = p->rchild = NULL;
if(*BT == NULL)
*BT = p;
else
{
switch(key)
{
case 1:
node[top]->lchild = p;
break;
case 2:
node[top]->rchild = p;
break;
}
}
}
ch = s[i++];
}
}
void main()
{
BitreeNode *Node;
CreateBiTree(&Node);
}
请问这是为什么?