这个类为什么会出错
#include <iostream>
using namespace std;
class Stack
{
public:
Stack();
~Stack();
char Spop();
void Spush(char);
void Slist();
private:
int Top;
char *Sta;
};
Stack::Stack()
{
Top=-1;
char *Sta=new char[50];
}
Stack::~Stack()
{
delete []Sta;
}
char Stack::Spop()
{
if ( -1 == Top)
{
return '0';
}
else
return Sta[Top--];
}
void Stack::Spush(char s)
{
Sta[++Top]=s;
}
void Stack::Slist()
{
while( -1 != Top )
{
cout<<Spop()<<endl;
Top--;
}
}
void main()
{
Stack s;
}
运行的时候出错了
[此贴子已经被作者于2006-10-18 14:45:27编辑过]