Using recursion, revise the destructor in the class LinkedListso that it deletes each node of the underlying linked chain.

What will be an ideal response?


```
template
LinkedList::~LinkedList()
{
deallocate(headPtr);
headPtr = nullptr;
itemCount = 0;
} // end destructor
// Private method: Deallocates all nodes assigned to the bag.
template
voidLinkedList::deallocate(Node* nextNodePtr)
{
if (nextNodePtr != nullptr)
{
Node* nodeToDeletePtr = nextNodePtr;
nextNodePtr = nextNodePtr->getNext();
delete nodeToDeletePtr;
deallocate(nextNodePtr);
} // end if
} // end deallocate

```

Computer Science & Information Technology

You might also like to view...

What is a record? What is a field? How are they represented in Access?

What will be an ideal response?

Computer Science & Information Technology

When contents of comments are too lengthy to show in a comment balloon, you can display them completely in the ________ Pane

Fill in the blank(s) with correct word

Computer Science & Information Technology

When defining a variable, the keyword ____ appears at the beginning of the statement.

A. Assign B. Declare C. Define D. Dim

Computer Science & Information Technology

List five tools that are borrowed from interaction design that can be applied during design planning stages

What will be an ideal response?

Computer Science & Information Technology