Following code is implementation of stacks..
but its giving two errors
# include<iostream.h>
# include<conio.h>
# define SIZE 20
class stack
{
int a[SIZE];
int top; // Top of Stack
public:
stack()
{
top=0;
}
int overflow()
{
if(top==SIZE)
{
return (1);
}
else
{
return (0);
}
}
int underflow()
{
if (top==0){
return 1; }
else{
return 0; }
}
void push(int i)
{
if(!overflow())
{
a[top]=i;
top++;
}
else
{
cout<<"Overflow";
}
}
int pop()
{
if(!underflow())
{
return(a[--top]);
}
else
{
cout<<"Underflow";
}
return 0;
};
void main()
{
stack new;
int ch=1,num;
while(ch!=0) [B] ERROR# 1[/B]
{
cout<<"Stack Operations"<<endl<<"1.Push"<<endl<<"2.Pop"<<endl<<" 3.Underflow"<<endl<<"4.Overflow"<<endl<<" 0.Exit";
cin>>ch;
switch(ch)
{
case 0:
exit(1); //Normal Termination of Program
case 1:
cout<<"Enter the number to push";
cin>>num;
new.push(num);
break;
case 2:
cout<<"Number popped from the stack is: "<<new.pop()<<endl;
break;
case 3:
if(!new.underflow())
{
cout<<"Not Empty"<<endl;
}
else
{
cout<<"Empty";
}
break;
case 4:
//(new.isfull())?(cout<<"Stack is full."):(cout<<"Stack is not full.");
break;
default:
cout<<"Illegal Option";
}
} //end of while
getch();
} [B] ERROR# 2[/B]
Error:1--Function containing while are not expanding INLINE
Error:2--Declaration terminated incorrectly..
im not getting it..:(