求二叉链表非递归先序序列


/*分别设计出先序、中序和后序遍历二叉树的非递归算法。
*/
#include 
using namespace std;
#define max 100
typedef char element;
typedef struct lBNode {
    element data;
    struct lBNode* lChild, * rChild;
}BiNode, * BiTree;
void  create(BiTree &T) {
    char ch;
     cin >> ch;
    if (ch == '#') {
        T = NULL;
        return;
    }
    else {
        T = new BiNode;
        T->data = ch;
        create(T->lChild);
        create(T->rChild);
    }
}
//顺序栈,元素为BiNode类型的指针
typedef struct sStack {
    BiNode data[max];
    int top;
}seqStack;
void initialStack(seqStack &S) {
    S.top = -1;
}
bool stackEmpty(seqStack& S) {
    if (S.top == -1)
        return true;
    else
        return false;
}
//取栈顶
bool stackTop(seqStack& S, BiNode* x) {
    if (stackEmpty(S))
        return false;
    else {
        *x = S.data[S.top];
        return true;
    }
}
//入栈
bool pushStack(seqStack& S, BiNode* x) {
    S.top++;
    S.data[S.top] = *x;
    return true;
}
//出栈
bool popStack(seqStack& S, BiNode*& x) {
    if (stackEmpty(S))
        return false;
    else {
        *x = S.data[S.top];
        S.top--;
        return true;
    }
}
//先序遍历非递归算法
void preTraverseNR(BiNode* T) {
    BiNode* p;
    seqStack S;
    initialStack(S);
    p = T;
    while (p || !stackEmpty(S)) {
        if (p) {
            cout << p->data << " ";
            pushStack(S, p);
            p = p->lChild;
        }
        else {
            popStack(S, p);
            p = p->rChild;
        }
    }
}
//中序遍历非递归算法
void InTraverseNR(BiNode* T) {
    BiNode* p;
    seqStack S;
    initialStack(S);
    p = T;
    while (p || !stackEmpty(S)) {
        if (p) {
            pushStack(S, p);
            p = p->lChild;
        }
        else {
            popStack(S, p);
            cout << p->data << " ";
            p = p->rChild;
        }
    }
}
//后序遍历非递归算法
void PostTraverseNR(BiNode* T) {
    BiNode* p;
    seqStack S;
    initialStack(S);
    int tag[max];//标记左子树,右子树
    int n;
    p = T;
    while (p || !stackEmpty(S)) {
        if (p) {
            pushStack(S, p);
            tag[S.top] = 0;//标记遍历左子树
            p = p->lChild;//循环遍历左子树
        }
        else {//左子树遍历完成
            stackTop(S, p);
            if (tag[S.top] == 0) {
                tag[S.top] = 1;
                p = p->rChild;
            }
            else {//左右子树均已经遍历
                popStack(S, p);
                cout << p->data << " ";
                p = NULL;
            }
        }
    }
}

int main() {
    BiNode* T=new BiNode;
    create(T);
     preTraverseNR(T);
    return 0;
}

img


如题,为什么入栈函数有问题呢,报错是什么意思?