Professional Documents
Culture Documents
Insurance
Insurance
class stackoverflow
public:
stackoverflow()
};
class stackunderflow
public:
stackunderflow()
};
class ArrayStack
private:
int data[MAX_SIZE];
int top;
public:
ArrayStack()
top=-1;
{
if(top>=MAX_SIZE)
data[++top]=element;
int pop()
if(top==-1)
return data[top--];
int Top()
return data[top];
int size()
return top+1;
bool isEmpty()
return(top==-1)?true:false;
};
int main()
ArrayStack s;
try{
if(s.isEmpty())
cout<<"stack is empty"<<endl;
s.push(100);
s.push(200);
cout<<"stack of stack:"<<s.size()<<endl;
cout<<s.Top()<<endl;
cout<<s.pop()<<endl;
cout<<s.pop()<<endl;
catch(...)
cout<<"some exception"<<endl;
return 0;