Hello everyone,
I do have this code that compiles, but it does not produce the order needed.
for instance if i add 3 numbers to the queue, (1,2,3) the display will print 2, 1, 3.
I think the problem is in the while loop but not sure.
code:
int quedue::enqueue(const journal_entry & to_add)
{
node *newnode = new node;
(newnode -> entry).copy_entry(to_add);
if(rear == NULL)
newnode -> next = newnode;
if(real != NULL)
{
newnode -> next = rear;
node *current = rear;
while(current -> next != rear)
current = current -> next;
current -> next = newnode;
}
rear = newnode;
return 1;
}
A (standard) queue is FIFO generally so 1 then 2 then 3 in should deliver 1 then 2 then 3 out but that's not what you say you are getting.
Please show us all your code so we can run it, and use the Format: <> on the right to put correct code tags.