You haven't shown the definition of n, but I have to assume it is:
|
node * n = nullptr; // List is empty to start
|
line 9: This for loop walks the linked list to find the last node. Note the ; at the end of the line. There is no executable statement that is iterated, other than what is in the for statement itself.
The for loop starts by setting r (curr node) to the global n, which we know is not null. Since there are no statements to execute, the increment expression (third term of for statement) is executed. r is replaced by r->link. r is now pointing to whatever the first node's r->link was pointing to, presumably, the second node and the for loop goes back to the top. R's forward pointer (link) is now checked for null. if not null, the increment expression is used to assign r's next pointer to r, so we're pointing to the next node in the list and the loop continues. If null, there is no next node and r is pointing to the last node of the linked list.
When we reach line 10, r is pointing to the last node in the list.
Line 10 then sets r->link to the new node (temp).