Each of the following member functions for performing an operation on a linked list of type NumberList has at least one error. Explain what is wrong and how to fix it.
A) NumberList::printList( )
{
while(head)
{
cout << head->value;
head = head->next;
}
}
B) NumberList::printList( )
{
ListNode *p = head;
while (p->next)
{
cout << p->value;
p = p->next;
}
}
C) NumberList::printList( )
{
ListNode *p = head;
while(p)
{
cout << p->value;
p++;
}
}
D) NumberList::~NumberList()
{
ListNode *nodePtr, *nextNode;
nodePtr = head;
while (nodePtr != NULL)
{
nextNode = nodePtr->next;
nodePtr->next = NULL;
nodePtr = nextNode;
}
}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.