//stack.h定义
#include<iostream>
#include<cassert>
#ifndef STACK
#define STACK
template<class T>
class stack{
int top;
T *a;
int cn;
public:
stack(int c);
~stack();
bool empty()const;
bool full()const;
void push(const T &item);
T gettop()const;
void pop();
void clear();
void display(const stack<T> &s1);
};
template<class T>//初始化栈,栈顶top=-1
stack<T>::stack(int c){
assert(c > 0);
cn = c;
a = new T[cn];//动态数组建立
if (a!= 0)
top = -1;
else
assert(a != 0);
}
template<class T>//析构函数调用清除动态数组
stack<T>::~stack(){
delete[]a;
}
template<class T>//判空,top=-1则为空
bool stack<T>::empty()const{
return(top == -1);
}
template<class T>//栈满判断
bool stack<T>::full()const{
return(top == cn - 1);
}
template<class T>//压栈,首先判断是否栈满
void stack<T>::push(cons