c++ - deleting a node from linked list, when we are already pointing to that node -


1->2->3->4 list, want delete 3rd node.

list *temp = *list; list *local = null;  if (temp->next != null) {     while(temp->next->data != data)         temp = temp->next;     local = temp->next;     temp->next = temp->next->next;      delete local;     local = null; } else {     delete (*list);     *list = null; } 

here using local node store node address temporarily , want remove, there way delete node without taking temporary variable ?


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -