strev
asked on
queue issue
null
In your DeQueue, shouldn't you check if the pointer is not NULL *before* you go ahead and delete it?
ASKER
i don't understand what you mean. I don't believe this answers my question, but thanks.
void IntQueue::Dequeue()
{
NodePtr tempPtr = front;
if (tempPtr != NULL )
{
front = tempPtr->link;
delete tempPtr;
if (front == NULL)
rear = NULL;
}
}
{
NodePtr tempPtr = front;
if (tempPtr != NULL )
{
front = tempPtr->link;
delete tempPtr;
if (front == NULL)
rear = NULL;
}
}
ASKER
Very interesting and it works. Now my issue is why? How is it that front was being set to NULL in my original Dequeue implementation? If you have time please respond. And how do I arrange to get you your points?
The code is kind of hard to read without indentation, but
it looks like you DeQueue regardless of whether something
was EnQueued first - you only call EnQueue if the
customer number > 0, but the DeQueue is called regardless
of the number.
Track the number of enqueues and dequeues with a debug
statement - the number should be the same.
As for arranging to get scrapdog his well deserved points,
he just has to put his solution (or any dummy text) in
as an answer, nothing you can do until then.
(ah, the joys of consumer/producer programming....)
pluim.
it looks like you DeQueue regardless of whether something
was EnQueued first - you only call EnQueue if the
customer number > 0, but the DeQueue is called regardless
of the number.
Track the number of enqueues and dequeues with a debug
statement - the number should be the same.
As for arranging to get scrapdog his well deserved points,
he just has to put his solution (or any dummy text) in
as an answer, nothing you can do until then.
(ah, the joys of consumer/producer programming....)
pluim.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again for the solution as well as the explanation. In future questions, I promise to indent as well. Pardon the faux pas.