// IntStack.cpp // Integer stack class member functions // CS210 - S'03 - 3/4/03 - Ray S. Babcock // #include "IntStack.h" IntStack::IntStack(int s) { if(s<0) s=10; size = s; top = -1; stackPtr = new int[size]; } IntStack::~IntStack() { delete [] stackPtr; } bool IntStack::push(const int & pushValue) { if(!isFull()) { stackPtr[++top]=pushValue; return true; } return false; } bool IntStack::pop(int & popValue) { if(!isEmpty()) { popValue = stackPtr[top--]; return true; } return false; } bool IntStack::isEmpty() const { return(top == -1); } bool IntStack::isFull() const { return(top == (size-1)); }