//stackx.cpp //methods for class Stack implemented using array //exception handling is used to deal with error conditions #include #include #include "stackx.h" #define BOS -1 Stack::Stack(int sz) { if (sz<0) size = abs(sz); else size = sz; val = new Type[size]; if (!val) throw "memory allocation error"; top = BOS; } void Stack::push(Type x) { if (isfull()) throw size; val[++top] = x; } Type Stack::pop() { if (isempty()) throw " stack underflow"; return val[top--]; } int Stack::isempty() { return top == BOS; } int Stack::isfull() { return top == size-1; } void Stack::print() { int i; for (i = top; i >= 0; i--) cout<