请问一下我的结构体有问题吗?


#include<iostream>
#include<stack>
using namespace std;
#define MAXSIZE 100
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int SElemType;

Typedef struct 
{
    SElemType *base;
    SElemType *top;
    int stacksize;
}SqStack;


Status InitStack(SqStack &S){
    S.base=new SElemType[MAXSIZE];
    if(!S.base)
        exit(OVERFLOW);
    S.top=S.base;
    S.stacksize=MAXSIZE;
    return OK;
}

Status Push(SqStack &s,SElemType e){
    if(S.top-S.base>=MAXSIZE)
        return ERROR;
    *S.top=e;
    S.top=S.top+1;
    return OK;
}

Status Pop(SqStack &S,SElemType &e){
    if(S.top==S.base)
        return ERROR;
    S.top=S.top-1;
    e=*S.top;
}

img


这是报错的内容

修改处见注释,供参考:

#include<iostream>
#include<stack>
using namespace std;
#define MAXSIZE 100
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int SElemType;
typedef int Status;    //修改
typedef struct sqstack //Typedef struct 修改
{
    SElemType *base;
    SElemType *top;
    int stacksize;
}SqStack;


Status InitStack(SqStack &S){
    S.base=new SElemType[MAXSIZE];
    if(!S.base)
        exit(OVERFLOW);
    S.top=S.base;
    S.stacksize=MAXSIZE;
    return OK;
}

Status Push(SqStack &S,SElemType e){ //SqStack &s, 修改
    if(S.top-S.base>=MAXSIZE)
        return ERROR;
    *S.top=e;
    S.top=S.top+1;
    return OK;
}

Status Pop(SqStack &S,SElemType &e){
    if(S.top==S.base)
        return ERROR;
    S.top=S.top-1;
    e=*S.top;
}