I was sitting in my car thinking about my LinkedList project when a question came up in my head regarding this particular code.
Node* current = head;
while (current != nullptr) {
// do stuff here
current = current->next; // -> Why does this not permanently affect the linkedlist?
}
In the comments I specify this. Why is setting current = current->next not permanent, yet when I add to the end of the Node the result is?
currentis not part of the linked list. You create it simply to keep track of the position.