while(nodePtr != NULL)
{
nodePtr=nextNode;
cout << "Deleting Element:" << endl;
nextNode=nextNode->next;
delete nodePtr;
}
Hi, you should change the sequence of your sentences and make some changes, since u need to change the pointer to the next element first and then delete the previous element. Otherwise, you will not get the value which element pointer points to. Check it again!