/** @file StackL.cpp */ #include "StackL.h" // header file Stack::Stack() { } // Copy constructor Stack::Stack(const Stack& aStack) : aList(aStack.aList) { } Stack::~Stack() { } bool Stack::isEmpty() const { return aList.isEmpty(); } void Stack::push(const StackItemType& newItem) throw(StackException) { try{ aList.insert(1, newItem); } catch (ListException e){ throw StackException("StackException: cannot push item."); } catch (ListIndexOutOfRangeException e){ throw StackException("StackException: cannot push item."); } } void Stack::pop() throw(StackException) { try{ aList.remove(1); } catch (ListIndexOutOfRangeException e){ throw StackException("StackException: stack empty on pop"); } } void Stack::pop(StackItemType& stackTop) throw(StackException) { try{ aList.retrieve(1, stackTop); aList.remove(1); } catch (ListIndexOutOfRangeException e){ throw StackException("StackException: stack empty on pop"); } } void Stack::getTop(StackItemType& stackTop) const throw(StackException) { try{ aList.retrieve(1, stackTop); } catch (ListIndexOutOfRangeException e){ throw StackException("StackException: stack empty on getTop"); } }