int get(){
if (head == 0) {
return -999;
}
else {
int v = head->item;
link t = head->next;
delete head; head = t;
return v;
}
}
Here is my switch case to call get function
if (q.get() != -999) {
cout << q.get() << " element removed from Queue" << endl;
}
else {
cout << "nothing to get; queue is empty" << endl;
}
when i get an element like 1 from get function, im getting "nothing to get; queue is empty"
message.
but i am able to get a correct element from the queue, but getting a wrong message. What is wrong in my code?
Aucun commentaire:
Enregistrer un commentaire