I'm really confused as to what exactly is going on here..
I have the function
void addToFront(int data)
{
Node* tmp = new Node();
tmp -> data = data;
tmp -> next = head;
head = tmp;
}
So when we do the line tmp-> next = head, we are making the tmp pointer point to what head is pointing to (the current first element of the list)? Because that's what it feels like, but wouldn't that just make it point to head? And then when we do head = tmp, we are making head point to the new node that we created, correct?