/** @file StackL.h * Stack ADT implementation using the list ADT implementation we saw in * chapter 4. */ #include #include #include "C4-ListP.h" // list operations using namespace std; typedef ListItemType StackItemType; /* * A user-defined exception class for the Stack ADT */ class StackException : public logic_error { public: StackException(const string& message = "") : logic_error(message.c_str()) {} }; /** @class Stack * ADT stack - ADT list implementation. */ class Stack { public: // constructors and destructor: /** Default constructor. */ Stack(); /** Copy constructor. */ Stack(const Stack& aStack); /** Destructor. */ ~Stack(); // Stack operations: bool isEmpty() const; void push(const StackItemType& newItem) throw(StackException); void pop() throw(StackException); void pop(StackItemType& stackTop) throw(StackException); void getTop(StackItemType& stackTop) const throw(StackException); private: /** List of stack items. */ List aList; };