请实现入栈和出栈的操作,规格如下:
class Stack {
public:
Stack();
voidpush(string value);
stringpop();//throw
PopEmptyStackException if stack is empty
} class Stack {
private int top=-1;
private String[] array=new String[MAX_LEN];
public:
Stack();
void push(String value)throws StackOverFlowException{
int index=++top;
if(index>=MAX_LEN){
throw New StackOverFlowException();
return ;
}
array[index]=value;
}
String pop()throws PopEmptyStackException{
if(top==-1){
throw new PopEmptyStackException();
return null;
}
return array[top--];
}
}