title: Does default destructor free the memory pointed by the member pointers?
body: <p>When I delete a node in a linked list, do I need to set the <code>next</code> to NULL?</p>
  
  <p>The ListNode is defined as this</p>
  
  <pre><code>struct ListNode {
      int val;
      ListNode* next;
      ListNode(int x): val(x) {}
  }
  </code></pre>
  
  <p>Now I wanna delete the node after <code>m</code></p>
  
  <pre><code>ListNode *tmp = m-&gt;next;
  m-&gt;next = m-&gt;next-&gt;next;
  delete tmp;
  </code></pre>
  
  <p>If <code>tmp-&gt;next</code> would be deleted in the destructor, the linked list should be in trouble. However, if <code>tmp-&gt;next</code> is not deleted, there could be another case that causes memory leak:</p>
  
  <pre><code>ListNode *tmp = new ListNode(0);
  tmp-&gt;next = new ListNode(1);
  delete tmp;
  </code></pre>
  
  <p>If <code>tmp-&gt;next</code> is not deleted, there's no way to find this piece of memory again.</p>
  
  <p>So it's a dilemma here, what does the default destructor actually do?</p>