|
| C++ Program Design, 3/e James P. Cohoon,
University of Virginia Jack W. Davidson,
University of Virginia
Lists
Chapter 9 OverviewIn many problem situations, a programmer needs the ability to define a group
of objects as either a one-dimensional or multidimensional list. For such tasks,
C++ provides two representation alternatives. One representation is based on
arrays; the other representation is based on classes. The array representation is
the traditional one and remains important because many legacy libraries work
only with this form of list. However, C++ imposes significant restrictions on the
use of arrays in an effort to maintain backward compatibility with C. In part
because of these restrictions and in part because of software-engineering
reasons, arrays are becoming less popular and class representations of lists are
becoming the dominant list representation. Several class representations for
lists are defined in the Standard Template Library (STL). These classes are
known as container classes because their objects can hold multiple values, and
the most important container class is the vector class. Our list examination
considers how to define and manipulate both array and vector objects. |
|
|