Revise the destructor in the class LinkedBagso that it does not call clear,butinstead directly deletes each node of the underlying linked chain.

What will be an ideal response?

```
template
LinkedBag::~LinkedBag()
{
while (headPtr != nullptr)
{
Node* nodeToDeletePtr = headPtr;
headPtr = headPtr->getNext();
// Return node to the system
nodeToDeletePtr->setNext(nullptr);
delete nodeToDeletePtr;
} // end while
// headPtr is nullptr
nodeToDeletePtr = nullptr;
itemCount = 0;
} // end destructor

```

Computer Science & Information Technology

You might also like to view...

What Windows components are kept in the WOW6432NODE folder?

A) 32-bit registry keys B) 32- and 64-bit device drivers C) 32- and 64-bit Windows file D) 32- and 64-bit Windows networking commands

Computer Science & Information Technology

Which is not an illusion of physical movement among screens?

A) scrolling B) context-sensitive pop-up windows C) onscreen dialogue D) None of the above.

Computer Science & Information Technology