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
Post a Comment