Deleting node from LinkedList I have this function to remove nodes that matches a certain criteria in the list. Initially when I wrote it, head node was not deleted if head-&gt;value was &gt;= delete_value, but other nodes in the list were deleted, so I decided to write the last if statement to only delete and amend the list if head-&gt;value was &gt;= delete_value.
It works, but I'm not sure if this is normal?

void remove(List * &amp; head, double value)
{
   if (head == NULL)
   {
    cout &lt;&lt; "Empty List";
    return;
   }

   if (head != NULL &amp;&amp; head-&gt;value != delete_value)
   {
    List* temp1 = head;
    List* temp2 = temp1-&gt;next;

       while (temp2 != NULL)
       {
          if (temp2-&gt;value &gt;= delete_value)
          {
            List* temp3 = temp2;
            temp2 = temp2-&gt;next;
            temp1-&gt;next = temp2;
            delete temp3;
          }
          else
          {
            temp1 = temp2;
            temp2 = temp2-&gt;next;
          }
       }
   }

   //This deletes head node, if value is greater than or equal to delete_value
   if (head != NULL &amp;&amp; head-&gt;value &gt;= delete_value)
   {
    List*temp = head;
    head = head-&gt;next;
    delete temp;
   }
return;
}
I believe these two lines are causing all the trouble.

 List* temp1 = head;
 List* temp2 = temp1-&gt;next;


temp2 never gets the head node because it is initialized as head-&gt;next to begin with.

I prefer double pointers since I find them rather cleaner.

void remove(Node&lt;ItemType&gt; * &amp; head, double value) {    
    Node&lt;ItemType&gt; **pp = &amp;head;
    Node&lt;ItemType&gt; *curr = head;
    while (curr) {
        if (curr-&gt;item == value) {
            *pp = curr-&gt;next;
            delete curr;
            curr = *pp;
        }
        else {
            pp = &amp;curr-&gt;next;
            curr = curr-&gt;next;
        }
    }
}