#include "Error.h" #include "StackError.h" const int SIZE = 100; class Stack { protected: int data[SIZE]; int tos; public: Stack() { tos = -1; } bool isEmpty() { return tos == -1; } bool isFull() { return tos == SIZE - 1; } void push(int elem); int pop(); }; void Stack::push(int elem) { if (isFull()) throw StackOverflowError("push", __FILE__, __LINE__); tos++; data[tos] = elem; } int Stack::pop() { if (isEmpty()) //throw StackUnderflowError("pop", __FILE__, __LINE__); throw StackUnderflowError(__FUNCTION__, __FILE__, __LINE__); int rlt = data[tos]; tos--; return rlt; }