class LIFO {
private:
int** elements;
int maximum;
int head;
public:
void empty()
bool isEmpty()
void pop()
bool push(int number)
int top()
}
void LIFO::empty() {
head = 0;
}
bool LIFO::isEmpty() {
return head == 0;
}
void LIFO::pop() {
if (head == 0) {
throw runtime_error("Alúlcsordulás")
} else {
head = head - 1;
}
}
bool LIFO::push(int number) {
if (head == maximum - 1) {
throw runtime_error("Túlcsordulás")
} else {
elements[head];
head = head + 1;
}
}
int LIFO::top() {
if (head == 0) {
throw runtime_error("Alúlcsordulás")
} else {
return elements[head - 1];
}
}