Link to home
Start Free TrialLog in
Avatar of strev
strev

asked on

queue issue

null
Avatar of scrapdog
scrapdog
Flag of United States of America image

In your DeQueue, shouldn't you check if the pointer is not NULL *before* you go ahead and delete it?  
Avatar of strev
strev

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;
  }
}

Avatar of strev

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.


ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of strev

ASKER

Thanks again for the solution as well as the explanation.  In future questions, I promise to indent as well.  Pardon the faux pas.