class LinkStackNode { public:
T data;
LinkStackNode< T >* link;
LinkStackNode(T& value):data( value ),link(NULL){} };
//栈类 template<class T > class LinkStack {
LinkStackNode< T >* tos; public:
LinkStack():tos(NULL){} void Push( T& value );
T Pop(); bool IsEmpty(); void ClearEmpty(); };
template<class T > void LinkStack< T >::Push( T& value ) {
LinkStackNode< T >* add =new LinkStackNode< T >( value );
add->data = value;
add->link = tos;
tos = add; }
template<class T >
T LinkStack< T >::Pop() { assert(NULL);
LinkStackNode< T >* old = tos;
T data1 = old->data;
tos = tos->link;
delete old;
return data1; }
template<class T > bool LinkStack< T >::IsEmpty() { if(NULL== tos ) returntrue; else returnfalse; }
template<class T > void LinkStack< T >::ClearEmpty() {
tos ==NULL; }