Linked List Destructor

How to write a 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.