13 template <
typename T,
int MAXSIZE>
30 void push(
const T& e);
43 template <
typename T,
int MAXSIZE>
47 throw std::out_of_range(
"Stack<>::pop(): empty stack");
52 template <
typename T,
int MAXSIZE>
55 if (numElems == MAXSIZE) {
56 throw std::out_of_range(
"Stack<>::push(): stack is full");
58 elems[numElems] = elem;
62 template <
typename T,
int MAXSIZE>
66 throw std::out_of_range(
"Stack<>::top(): empty stack");
68 return elems[numElems - 1];
void pop()
Pop element off the stack.
bool full() const
Check wheter stack is full.
void push(const T &e)
Pushes element onto stack.
std::vector< T > elems
Container for the stack elements.
bool empty() const
Check whether stack is empty.
Stack class using vector as element container.
T top() const
Return top element of the stack (but not pop-ing it).
unsigned int numElems
Current number of elements.