Copyright © 1999-2011 Steven J. Zeil, Old Dominion University
Table of Contents
Next we turn our attention to a set of issues that are often given short shrift in both introductory courses and textbooks, but that are extremely important in practical C++ programming.
As we begin to build up our own ADTS, implemented as C++ classes, we quickly come to the point where we need more than one of each kind of ADT object. Sometimes we will simply have multiple variables of our ADT types. Once we do, we will often want to copy or assign one variable to another, and we need to understand what will happen when we do so. Even more important, we need to be sure that what does happen is what we want to have happen, depending upon our intended behavior for our ADTs.
As we move past the simple case of multiple variables of the same ADT type, we may want to build collections of that ADT. The simplest case of this would be an array or linked list of our ADT type, though we will study other collections as the semester goes on. We will need to understand what happens when we initialize such a collection and when we copy values into and out of it, and we need to make sure that behavior is what we want for our ADTs.
In this lesson, we set the stage for this kind of understanding by looking at how we control initialization and copying of class values.