#include<iostream>
#include<string>
using namespace std;
template<class T>
struct Node{
T data;
Node<T>*next;
};
template<class T>
class Student{
public:
Student(){top=NULL;}
~Student(){}
void push(T x);
T pop();
T gettop(){if(top!=NULL) return top->data;}
int empty(){if(top==NULL)return 1;return 0;}
private:
Node<T>*top;
};
template<class T>
void Student<T>::push(T x){
Node<T>*s;
s=new Node<T>;
s->data=x;
s->next=top;
top=s;
}
template<class T>
T Student<T>::pop(){
if(top==NULL)throw "下溢";
T x=top->data;
Node<T> *p;
p=top;
top=top->next;
delete p;
return x;
}
void main(){
Student<string> stu;
string a[3]={"小明","小李","小栋"};
for(int i=0;i<3;i++){
stu.push(a[i]);
}
cout<<stu.gettop()<<endl;
cout<<stu.pop()<<endl;
cout<<stu.empty()<<endl;
}