新手上路,请大神们多多帮助。为什么创建二叉树时Create的形参为Tnode &T,而不能为PBinTree*T。
#include "stdafx.h"
#include <stdio.h>
typedef char DataType;
typedef struct node
{
DataType data;
struct node *lchild, *rchild, *parent;
}PBinTree,*Tnode;
void Create(Tnode &T)
{
char ch;
scanf_s("%c", &ch);
if ('#' == ch) //以字符#表示结点元素为空
{
T = NULL;
}
else {
T = new PBinTree();
T->data = ch;
T->parent = NULL;
Create(T->lchild);
Create(T->rchild);
}
return ;
}
void main()
{
PBinTree* T=NULL;
printf("请输入以先序序列创建的二叉树:");
Create(T);
return ;
}