// class template of the stack ADT // The member functions are defined outside of the class declaration const int STACK_CAPACITY=10; template class Stack { public: Stack(); void push(stackElement); void pop(); stackElement top(); bool isEmpty(); bool isFull(); private: stackElement stackArray[STACK_CAPACITY]; int stackTop; }; template Stack<stackElement>::Stack() { stackTop=-1; } template void Stack<stackElement>::push(stackElement x) { if(!isFull()) { stackTop++; stackArray[stackTop]=x; } else cout<<"Push oporation failed. The stack is full."<<endl; } template void Stack<stackElement>::pop() { if (!isEmpty()) { stackTop -- ; } else cout<<"Pop operation failed. The stack is empty."<<endl; } template stackElement Stack<stackElement>::top() { return stackArray[stackTop]; } template bool Stack<stackElement>::isEmpty()
{ }
return (stackTop==-1);
template bool Stack<stackElement>::isFull() { return (stackTop==STACK_CAPACITY-1); }