I am trying to do a simple queue using linked list. I am failing to perform dequeue because I cant get the logic straight. If there is anyone who could explain to me about the simple logic of this then it would help alot. Thanks. I have also posted the small code that is giving me the problem
bool dequeue(int& new_num)
{
myPtr tmp_ptr;
tmp_ptr=head;
if (isEmpty())
{
cout<<"The queue is empty"<<endl;
return false;
}
else
{
for(int i=0;i<counter;i++)
{
new_num=head->num;
tmp_ptr=head->link;
delete head;
head=tmp_ptr;
}
return true;
}
}