#ifndef EXERCISES_HH
#define EXERCISES_HH
#include <list>
template<typename T>
class Stack
{
public:
bool isEmpty() const;
void push(T const &e);
T const &pop();
private:
std::list<T> _stack;
};
#include "exercises.tcc"
#endif
template<typename T>
T abs(T const &x)
{
if(x < 0)
return -x;
return x;
}
template<typename T>
bool Stack<T>::isEmpty() const
{
return _stack.empty();
}
template<typename T>
void Stack<T>::push(T const &e)
{
_stack.push_front(e);
}
template<typename T>
T const &Stack<T>::pop()
{
T const &first = _stack.front();
_stack.pop_front();
return first;
}
template<int SIZE, typename T>
T *makeArray(T const &e)
{
T *array = new T[SIZE];
for(int i = 0; i < SIZE; ++i)
array[i] = e;
return array;
}