Queue empty or not
So my friend is saying to write :
1 2 3 4
|
if (front == - 1 || front > rear)
{
cout<<"Queue Underflow "
}
|
to check the queue is empty or not! But don't you think that
1 2 3 4
|
if (rear == -1)
{
cout<<"Queue Underflow "
}
|
is enough?. Because rear is gonna increment only after each push!
Your question is very light on details. Details you need to tell us so we can help you.
If you are using a
std::queue, use the container's
empty() member function to find out if it is empty.
http://www.cplusplus.com/reference/queue/queue/empty/
If you are using some other type of container, one that isn't part of the C++ standard library, ask your friend.
Topic archived. No new replies allowed.