#include<iostream>
using namespace std;
const int size=10;
template<typename Type>
class Stack
{
public:
void init()
{tos=0;}
void push(Type ch);
Type pop();
private:
Type stck[size];
int tos;
};
template<typename Type>
void Stack<Type>::push(Type ob)
{
if(tos==size)
{cout<<"Stack is full";
return;
}
stck[tos]=ob;
tos++;
}
template<typename Type>
Type Stack<Type>::pop()
{
if(tos==0)
{cout<<"Stack is empty";
return 0;
}
tos--;
return stck[tos];
}
int main()
{
//定义整形堆栈
Stack<int>is;
int i;
is.init();
is.push(2);
is.push(88);
is.push(9);
is.push(4);
for(i=0;i<4;i++)
cout<<"pop is:"<<is.pop()<<endl;
struct CHAP5
{
char * pName;
bool Gender;
int Age;
struct CHAP5 * next;
};
struct Node_int
{
int i;
struct Node_int * next;
};
Stack<CHAP5>jg
jg.init();
jg.push("pan",true,20,*p);
/*CHAP5.push(88);
CHAP5.push(9);
CHAP5.push(4);*/
cout<<"pop is:"<<jg.pop()<<endl;
return 0;
}