How to write a linked list destructor??
Linked List Destructor
Hello @ParvBudh,
You can refer to the following code for destructing the linked list:
node* current = head; node* next;
//Repeat for all nodes of linked list
while (current != NULL) {
//save next node
next = current->next;
//delete current node
delete current;
//make the next node as current
current = next;
}
Hope, this would help.
Give a like, if you are satisfied.