// Means while conductor isn't 0 run the if statement
if (conductor != 0) {
// Checks weather the next node in the list is pointing to something
while (conductor->next != 0)
// If the next node is pointing to something it tells the conductor to point to the next node
conductor = conductor->next;
}
Next is a pointer to the next node in the list. If next isn't NULL (or 0), which signifies the end of the list, the conductor (also a pointer to a node) is set to whichever node is held in next.
Okay so conductor != 0 references which part of the code however? Next I perfectly understand as NULL signifies the end of the list, but conductor != 0 is where I get confused.
Yeah, it's first checking to make sure that conductor isn't null. Then it keeps jumping to the next linked node, providing that the next node isn't null as that would be the end of the list.
node *root; // This won't change, or we would lose the list in memory
node *conductor; // This will point to each node as it traverses the list
root = new node; // Sets it to actually point to something
root->next = 0; // Otherwise it would not work well
root->x = 12;
So this right here... focusing on the root->next=0; does it set the next node to 0 or the first node to 0?