i have a code that causes errors in running the program...i use my header file stack.h on my program but it didn't work...what is the problem of that program?
Code:
#define DEFAULT_SIZE 10
class stack//declaration syntax error
{
private:
int size;
int top;
int *values;
public:
stack(int size=DEFAULT_SIZE);
/*virtual*/~stack();
int isFull();
int isEmpty();
void push(int);
int pop(int);
}
stack::stack(int size)
{
this->size=size;
values=new int [size];
top=-1;
}
stack::~stack()
{
delete [] values;
}
int stack::isFull()
{
if(top<size-1)
{
return 0;
}
else
{
return 1;
}
}
int stack:: isEmpty()
{
if(top==-1)
{
return 1;
}
else
{
return 0;
}
}
void stack:: push(int x)
{
if(!isFull())
{
top++;
values[top]=x;
}
}
int stack::pop(int top)
{
int retVal=0;
if(! isEmpty())
{
retVal=values[top];
top--;
}
return retVal;
}