#include<cstdio>
#include<cstring>
#include<algorithm>
#include <iostream>
using namespace std;
const int Max = 100;
class Stack
{
private:
char* date;
int size;
int top;
public:
Stack();
Stack(int s);
~Stack();
void push(char ch);
char pop();
char getTop();
bool isEmpty();
bool isFull();
void setNull();
};
Stack::Stack()
{
size = Max;
top = -1;
date = new char[Max];
}
Stack::Stack(int s)
{
size = s;
top = -1;
date = new char[size];
}
Stack::~Stack()
{
delete[] date;
}
void Stack::push(char ch)
{
if (!isFull())
{
date[++top] = ch;
}
}
char Stack::pop()
{
if (!isEmpty())
{
return date[top--];
}
}
char Stack::getTop()
{
if (!isEmpty())
{
return date[top];
}
}
bool Stack::isEmpty()
{
if (top == -1)
{
return true;
}
else
{
return false;
}
}
bool Stack::isFull()
{
if (top +1 == size)
{
return true;
}
else
{
return false;
}
}
void Stack::setNull()
{
top = -1;
}
int main()
{
Stack s1(2);
s1.push('a');
s1.push('b');
cout << s1.isFull() << endl;
cout << s1.getTop() << endl;
cout << s1.pop() << endl;
cout << s1.pop() << endl;
cout << s1.isEmpty() << endl;
}