// Stack class interface: array implementation // // Etype: must have zero-parameter constructor and operator= // CONSTRUCTION: with (a) no initializer; // copy construction of Stack objects is DISALLOWED // Deep copy is not supported // // ******************PUBLIC OPERATIONS********************* // void Push( Etype X ) --> Insert X // void Pop( ) --> Remove most recently inserted item // Etype Top( ) --> Return most recently inserted item // int IsEmpty( ) --> Return 1 if empty; else return 0 // void MakeEmpty( ) --> Remove all items // ******************ERRORS******************************** // Predefined exception is propogated if new fails // EXCEPTION is called for Top or Pop on empty stack #ifndef __Stack_H #define __Stack_H #include "Vector.h" template class Stack { public: Stack( ) : Array( 5 ), TopOfStack( -1 ) { } ~Stack( ) { } void Push( const Etype & X ); void Pop( ); const Etype & Top( ) const; int IsEmpty( ) const { return TopOfStack == -1; } void MakeEmpty( ) { TopOfStack = -1; } private: // Copy constructor disabled because of Vector // Disable operator= const Stack & operator=( const Stack & Rhs ) { return *this; } int TopOfStack; Vector Array; }; #endif