#include <iostream>
#define MAXSIZE 50
using namespace std;
class stack{
int top,a[MAXSIZE];
public:
stack()
{
top=-1;
}
void push(int x)
{
if(top==MAXSIZE)
cout<<"Stack is full";
else{
top++;
a[top]=x;
}
}
int pop()
{
if(top==-1)
cout<<"Stack is empty";
else{
int x=a[top];
top--;
return x;
}
}
};
int main()
{
stack s;
s.push(5);
s.push(6);
cout<<s.pop();
}
Note: Need to be arranged in compiler after copied
OutPut:
6