Queue

Please explain the following

Node*temp;
temp=New node;
temp->Next=NULL;
rear->NEXT=temp;
rear=temp;
The queue is implemented as a forward linked list.
A new element is added to the queue.

Say what exactly you do not understand about the code.
Why do you ask? Is it your homework to work out the logic of a code sample, or do you just read code samples and haven't yet learned to work out the logic?

Appends a new node into a singly linked list, whose last node is kept track of. No value is set.

Line 2 contains two errors: New is not a keyword and a type mismatch. (C++ is case sensitive)
Line 3 shows that the object type lacks a constructor that would initialize members sensibly.
Line 4 shows a (case sensitivity) typo, if typeof(rear) == typeof(temp), and line 5 hints that this is the case
Last edited on
Topic archived. No new replies allowed.