Hello
I have 2 ways to delete a linked list, which one is correct?
If I have this linked list:
list = 1 - 2 - 3- 4
Which function will delete list correctly?
1.
void destroy(node * & list)
{
while (list != NULL) {
delete list;
list = list->next;
}
}
2.
void destroy(node * & list)
{
delete list;
}