// This is the header file from Display 17-17. This is the interface for the class Stack, // which is a template class for a stack of items of type T. // // It is the same file as stack.h. // #ifndef STACK_H #define STACK_H namespace StackSavitch { template class Node { public: Node(T theData, Node* theLink) : data(theData), link(theLink){} Node* getLink( ) const { return link; } const T getData( ) const { return data; } void setData(const T& theData) { data = theData; } void setLink(Node* pointer) { link = pointer; } private: T data; Node *link; }; template class Stack { public: Stack( ); //Initializes the object to an empty stack. Stack(const Stack& aStack); Stack& operator =(const Stack& rightSide); virtual ~Stack( ); void push(T stackFrame); //Postcondition: stackFrame has been added to the stack. T pop( ); //Precondition: The stack is not empty. //Returns the top stack frame and removes that top //stack frame from the stack. bool isEmpty( ) const; //Returns true if the stack is empty. Returns false otherwise. private: Node *top; }; }//StackSavitch #endif //STACK_H