/* CS19 C++ Spring 2004 * intstack.h (assignment starter file) * Steve J. Hodges */ //#include //using namespace std; #ifndef INTSTACK_H #define INTSTACK_H /* A Stack is a LIFO (Last-In, First-Out) Data Structure * This static stack holds up to MAXSTACKSIZE integers * To add an integer, use the push function * To remove an integer, use the pop function * Functions isFull and isEmpty return stack information * This stack is implemented using an array */ class intStack{ public: intStack(){ size=0; } int pop(){ if(isEmpty()) return EMPTY; size--; return s[size]; } void push(int n){ if(!isFull()){ s[size] = n; size++;} } bool isFull()const{ return size==MAXSTACKSIZE; } bool isEmpty()const{ return size==0; } private: int size; static const int MAXSTACKSIZE = 50; static const int EMPTY = -1; int s[MAXSTACKSIZE]; }; #endif