这个小程序有问题 请大家帮忙指出错误在哪里?谢谢大家了
#include<iostream.h>
#define MAX 100
class stack
{
public:
stack(){}
stack(int s)
{
top=0;
bottom=0;
size=s;
}
int pop();
void push(int i);
bool empty();
void disp();
private:
int top;
int bottom;
int size;
int a[MAX];
};
stack::void push(int i)
{
if(top-bottom<=size)
{
a[top]=i;
}
top=top+1;
}
stack::int pop()
{
if(--top>=bottom)
{
return a[bottom];
}
else
cout<<"this is a empty stack"<<endl;
}
stack::bool empty()
{
if(top==bottom)
return true;
else
return false;
}
stack::void disp()
{
for(int i=0;i<top;i++)
{
cout<<a[i]<<" ";
}
}
int main()
{
stack m(4);
m.push(2);
m.push(3);
m.push(4);
m.push(5);
m.disp();
return 0;
}