Revise the program in Listing 4-4 so that it tests first the link-based implementationand then the array-based implementation. Ensure that the program does not have amemory leak.

What will be an ideal response?

```
int main()
{
BagInterface* bagPtr = new LinkedBag();
std::cout << "Testing the Link-Based Bag:" < std::cout << "The initial bag is empty." < bagTester(bagPtr);
delete bagPtr;
std::cout < bagPtr = new ArrayBag();
std::cout << "Testing the Array-Based Bag:" < std::cout << "The initial bag is empty." < bagTester(bagPtr);
delete bagPtr;
bagPtr = nullptr;
std::cout << "All done!" << std::endl;
return 0;
} // end main

```

Computer Science & Information Technology

You might also like to view...

If a document is changed after the table of contents was created, then the table of contents needs to be updated

Indicate whether the statement is true or false

Computer Science & Information Technology

The ________ button will remove all items from the Office Clipboard

A) Clear All B) Remove All C) Close D) Cut

Computer Science & Information Technology