填空题
请将下列栈类Stack补充完整。
class Stack{
private:
int pList[100]; //int数组,用于存储占的元素
int top; //栈顶元素(数组下标)
public:
Stack( ):top(0){ }
void Push(const int&item); //新元素item压入栈
int Pop(void); //将栈顶元素弹出栈
};
void Stack::Push(const int&item){
if(top==99) exit(1); //如果栈满,则程序终止
top++; //栈顶指针增1
______;
}
int Stack::Pop( ){
if(top<0) exit(1); //如果栈空,则程序终止
return Plist[top--];
}
【参考答案】
plist[top]=item