#include "mydefs0.h" // Array implementation of stacks. // Grow from high index towards 0. int_stack :: int_stack(int nitems = 100) { sz = nitems; // specified size stack = new int[sz]; top = sz; } int_stack :: int_stack() { sz = 100; // default size stack = new int[sz]; top = sz; } /* int_stack :: int_stack (int nitems = 100) { sz = nitems; stack = new int [sz]; top = sz; } */ int_stack :: ~int_stack () { cout << "getting rid of the array of size " << sz << endl; delete [] stack; } void int_stack :: push(int x) { assert( !isfull() ); stack[--top] = x; } int int_stack :: pop() { assert( !isempty() ); return( stack[top++] ); } bool int_stack :: isempty() { return( top == sz ); } bool int_stack :: isfull() { return( top == 0 ); }