#include<iostream>
using namespace std;
class Point{
int data;
public:
int getdata();
bool setdata(int data);
};
int Point::getdata(){
return this->data;
}
bool Point::setdata(int data){
this->data = data;
}
class Stack{
Point *top;
Point base[100];
int length;
public:
Stack();
int topp();
bool push(int data);
bool pop();
bool emp();
int size();
};
Stack::Stack(){
top = base;
length = 0;
}
int Stack::topp(){
if(length == 0)
return 0;
return (top-1)->getdata();
}
bool Stack::push(int data){
if(length == 100)
return 0;
top->setdata(data);
top++;
length++;
return 1;
}
bool Stack::pop(){
if(base == top)
return 0;
top--;
length--;
return 1;
}
bool Stack::emp(){
if(base == top)
return 1;
else
return 0;
}
int Stack::size(){
return length;
}
main(){
Stack s = Stack();
s.push(1);
cout<<s.topp()<<endl;
s.push(2);
cout<<s.topp()<<endl;
s.push(3);
cout<<s.topp()<<endl;
s.push(4);
cout<<s.topp()<<endl;
s.push(5);
cout<<s.topp()<<endl;
for (int i=0; i<5; i++){
cout<<s.topp()<<endl;
s.pop();
}
}