#include
using namespace std;
class tree {
public:
char val;
tree* lchild;
tree* rchild;
void creatTree(tree* &T)
{
char ch;
ch = getchar();
if (ch == '#')
{
T = NULL;
}
else
{
T = new tree;
T->val = ch;
creatTree(T->lchild);
creatTree(T->rchild);
}
}
void VLR(tree* T)
{
if (T == NULL)
{
return;
}
else {
cout << T->val;
VLR(T->lchild);
VLR(T->rchild);
}
}
};
int main()
{
tree t;
tree* T;
t.creatTree(T);
t.VLR(T);
}
在 void creatTree(tree* &T)中去掉&就会报错这是为什么?