weixin_44121669
Eip_Nit_AC
2019-05-23 14:38

为什么p St b报错“表达式必须包含指向类的指针类型”?

  • c++
#include<iostream>
#include<stdlib.h>
#define MaxSize 50

typedef int ElemType;
typedef struct Node *Position;
typedef Position BTNode;
struct Node
{
    ElemType data;
    struct node *lchild;
    struct node *rchild;
}b;

void CreateBTree(BTNode * &b, char*str)
{
    BTNode *St[MaxSize], *p;
    int top = -1, k, j = 0;
    char ch;
    b = NULL;
    ch = str[j];
    while (ch != '\0')
    {
        switch (ch)
        {
        case '(':top++; St[top] = p; k = 1; break;
        case')':top--; break;
        case',':k = 2; break;
        default:p = (BTNode *)malloc(sizeof(BTNode));
            p->data = ch;
            p->lchild = p->rchild = NULL;
            if (b == NULL)
                b = p;
            else
            {
                switch (k)
                {
                case 1:St[top]->lchild = p; break;
                case 2:St[top]->rchild = p; break;
                }
            }
        }
        j++;
        ch = str[j];
    }
}

图片说明
图片说明
其中p St b报错“表达式必须包含指向类的指针类型”
请问大佬们这是为什么呀?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答