0 tmp head head head next head head delete tmp delete

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: p; while (Head != 0) { tmp = Head; Head = Head->next; Head Head delete tmp; delete tmp } Again no type. The implementation must clean up all The dynamic memory. dynamic } Here it is. Applied Programming Let's look at an example to see the power of Let's classes. classes. Consider a supermarket with n checkouts. Consider Applied Programming Ask for the size of the supermarket cout << "How many checkouts? "; cin >> n; Create the required number of checkouts. Each checkout has its own queue. checkout = new LinkedList[n]; checkout LinkedList[n W e'll dynamically allocate the queues so that we We'll do not limit the number n. So LinkedList *checkout; int n; Applied Programming C++ will call the constructor for each of the n C++ entries, which we can refer to as checkout[0], . . . checkout[i], . . . checkout[0], checkout[i], Applied Programming Once we have carried out our simulation of the Once supermarket, we can then free up our dynamically allocated space by allocated delete checkout; which will invoke the de...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online