So my Turbo C doesn't handle errors. And in school we used VC++ but I don't have it at home. So can anyone tell if the code snippets for Queue and Dequeuing a Queue and Pop and Push operations in Stack are right?
\int queue::dequeue()
{
try
{
if(front>rear)
throw 0;
}
catch(int)
{
cout<<"queue is empty\n";
return 0;
}
return a[rear];
}
void queue::enqueue(int ch)
{
try
{
if(cap==size)
throw size;
}
catch(int)
{
cout<<"queue is full\n";
return;
}
a[++rear]=ch;
size++;
}
void stack::push(int op)
{
try
{
if(top==SIZE)
throw top;
}
catch(int)
{
cout<<"Stack is Full \n";
return;
}
++top;
stck[top]=op;
}
int stack::pop()
{
try
{
int(top==0)
throw 0;
}
catch(int)
{
cout<<"Stack is Empty!\n";
return 0;
}
top--
return stck[top];
}