Chapter 43: | How To Reclaim Memory with Delete and Destructors |
At this point, the latest version of the analyze_train
programthe
one shown in Segment 627extracts serial numbers from a
train-describing file, uses the numbers to identify car type, stores the
numbers, and displays a report. Along the way, the program creates new
class objects that are accessed through an array of pointers.
You soon learn about still another version of analyze_train
that
waits for you to type the name of a train file, whereupon it does its job,
producing a new report. Then, the modified program repeats the waitwork
cycle ad infinitum.
You soon see that the modified program creates class objects that become not only obsolete, but also inaccessible. That brings you to the heart of this chapter, where you learn how to reclaim the memory used for such class objects.