程序编译没问题,运行时错误
#include "stdafx.h"
#include <iostream.h>
const int SIZE=10;
class stack
{
int * data;
int tos;
public:
stack();
void push(int a);
//pop();
//showstack();
};
stack::stack()
{
tos=0;
cout<<"hello!";
}
void stack::push(int a)
{
if (tos==SIZE)
cout<<"the stack is full!"<<endl;
else
{
data[tos]=a;
++tos;
cout<<"input "<<a<<endl;
}
}
int main()
{
stack obj;
int i=0;
obj.push(i);
return 0;
}
初学者,呵呵~~请问这个程序有什么问题?