title: Linked list deep copy constructor
body: <p>I am implementing a linked list class' copy constructor which will make a deep copy. This is the code that i have:</p>
  
  <pre><code>List( const List &amp; rhs ) {
          Node* rhsFront = rhs.header-&gt;next;
          Node* prev = header;
          while (rhsFront) {
              prev-&gt;next = new Node(rhsFront-&gt;data, nullptr);
              rhsFront = rhsFront-&gt;next;
              prev = prev-&gt;next;
          }
  }
  </code></pre>
  
  <p>However, it crashes at this line:</p>
  
  <pre><code>prev-&gt;next = new Node(rhsFront-&gt;data, nullptr);
  </code></pre>
  
  <p>What did I do wrong?</p>