title: Adding node to the front of a linked list
body: <p>I'm really confused as to what exactly is going on here..</p>
  
  <p>I have the function </p>
  
  <pre><code>void addToFront(int data)  
  {
    Node* tmp = new Node();
    tmp -&gt; data = data;
    tmp -&gt; next = head;
    head = tmp;
  }
  </code></pre>
  
  <p>So when we do the line <code>tmp-&gt; next = head</code>, we are making the <code>tmp</code> pointer point to what <code>head</code> 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 <code>head</code>? And then when we do <code>head = tmp</code>, we are making head point to the new node that we created, correct?</p>