Code /* stack.h CIS 250 Dave Klick Definition and implementation of a stack class for integer values which uses an array for storage. This class should really overload the assignment operator and copy constructor, but doesn't at the moment. */ #ifndef __STACK_H_ #define __STACK_H_ #include class stack { private: int* stk; int numItems; int size; void init(const int size); public: stack(); stack(const int size); ~stack(); bool isEmpty() const; bool isFull() const; bool push(const int data); bool pop(int& data); }; stack::stack() { init(10); } stack::stack(int size) { init(size); } void stack::init(const int len) { size = len>0 ? len : 10; stk = new int[size]; numItems = 0; } stack::~stack() { if (stk) delete[] stk; stk = NULL; numItems = 0; size = 0; } bool stack::isEmpty() const { return numItems==0; } bool stack::isFull() const { return numItems==size; } bool stack::push(const int data) { if (isFull()) return false; stk[numItems++] = data; return true; } bool stack::pop(int& data) { if (isEmpty()) return false; data = stk[--numItems]; return true; } #endif