template <class T>
class Stack
{
private:
enum {
MAXSIZE=128
};
T stacklist[MAXSIZE];
int top;
public :
void push(const T&item);
Stack<T> & operator =(Stack<T> const & src);
T pop(void);
Stack();
~Stack();
void clearstack();
};
template <class T>
Stack<T>::Stack():top(-1){}
template<class T>
Stack<T> & Stack<T>::operator =(Stack<T> const & src)
{
if((void *)this==(void *src))
return *this;
}
template <class T>
void Stack<T>::push(const T&item)
{
if(top==MAXSIZE-1)
{
return NULL;
}
top++;
stacklist[top]=item;
}
template <class T>
T Stack<T>::pop()
{
T temp;
if(top==-1)
{
cerr<<"empty "<<endl;
return 0;
}
temp=stacklist[top];
top--;
return temp;
}
template <class T>
void Stack<T>::clearstack()
{
memset(stacklist,0x00,MAXSIZE);
top=-1;
}