#include <iostream>
using namespace std;
class Stack
{
public:
Stack();
Stack(int _size);
~Stack();
bool empty();
int top();
bool pop();
bool push(int element);
int size();
private:
int *data;
int top;
int size;
};
Stack::Stack()
{
data = new int[100];
top = -1;
size = 100;
}
Stack::Stack(int _size)
{
data = new int[size];
size = _size;
top = -1;
}
Stack::~Stack()
{
delete []data;
}
bool Stack::empty()
{
return top == -1? true : false;
}
int Stack::top()
{
if(empty())
{
return ;
}
return data[top];
}
bool Stack::push(int element)
{
if(top == size - 1)
{
return false;
}
top ++;
data[top] = element;
}
bool Stack::pop()
{
if(top > -1)
{
top --;
}
}
int Stack::size()
{
return top+1;
}