#include
#define node 1000
using namespace std;
//////////////////////////定义模板
templateclass stack{
type stac[node];
int top;
public:
stack(){top=-1;}
void push_s(type ch);
type get_s();
};
templatevoid stack::push_s(type ch)
{
if(top stac[++top]=ch;
else
{
cout<<"The stack is full!"< return ;
}
}
templatetype stack::get_s()
{
if(top==-1)
{cout<<"The stack is emty!"< return 2;
}
else
return stac[top--];
}
//////////////////////////////////////////模板定义完毕
main()
{
stackstack1;
for(int i=0;i {
cout< stack1.push_s(i);
}
cout< for(i=0;i {
cout< }
cout< return 3;
}
--------------------next---------------------
阅读(981) | 评论(0) | 转发(0) |