填空题

下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。 #define MAXSIZE 100 template <class T> class Stack { T s[MAXSIZE]; int top; public: stack() { top=1; } void push(T newValue) { if(top<MAXSIZE) { top=top+1; s[top]=newValue; } else cout<<"堆栈满,无法进栈"<<end1; } void pop(); }; 【12】 { if(top>1) { cout<<s[top]<<end1; top=top-1; } else cout<<"堆栈空! "<<end1; }

【参考答案】

template<classT>/voidstack<T>::pop()