#include "mydefs1.h" // Array implementation of stacks. // Grow from high index towards 0. int_stack :: ~int_stack () { cout << "Deleting stack of size " << sz << endl; delete [] stack; } void int_stack :: init(int nitems) { sz = nitems; //specified size stack = new int[sz]; top = sz; } void int_stack :: init() { sz = 100; // default size stack = new int[sz]; top = sz; } 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 ); }