#include "mydefs1.h" #include // Array implementation of stacks. // Grow from high index towards 0. void Istack :: init(int nitems = 100) { sz = nitems; stack = new int[sz]; top = sz; } void Istack :: push(int x) { assert( !isfull() ); stack[--top] = x; } int Istack :: pop() { assert( !isempty() ); return( stack[top++] ); } bool Istack :: isempty() { return( top == sz ); } bool Istack :: isfull() { return( top == 0 ); }