/* ECP: FILEname=fig14_25.cpp */ /* 1*/ template /* 2*/ inline int /* 3*/ Stack::IsEmpty( ) const /* 4*/ { /* 5*/ return TopOfStack == -1; /* 6*/ } /* 1*/ template /* 2*/ void /* 3*/ Stack::Push( const Etype & X ) /* 4*/ { /* 5*/ if( ++TopOfStack == MaxSize ) /* 6*/ DoubleArray( Array, MaxSize ); /* 7*/ Array[ TopOfStack ] = X; /* 8*/ } /* 1*/ template /* 2*/ const Etype & /* 3*/ Stack::Pop( ) /* 4*/ { /* 5*/ if( IsEmpty( ) ) /* 6*/ { /* 7*/ cerr << "Pop on empty stack" << endl; /* 8*/ return Array[ 0 ]; /* 9*/ } /*10*/ else /*11*/ return Array[ TopOfStack-- ]; /*12*/ } /* 1*/ template /* 2*/ inline void /* 3*/ Stack::ClearStack( ) /* 4*/ { /* 5*/ TopOfStack = -1; /* 6*/ }