Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |
Container classes are the
solution to a specific kind of code reuse problem. They are building blocks
used to create object oriented programs, and they make the internals of a
program much easier to construct.
A container class describes an object that holds other
objects. Container classes are so important that they were considered
fundamental to early object-oriented languages. In Smalltalk, for example, programmers
think of the language as the program translator together with the class
library, and a critical part of that library is the set of container classes. It
became natural, therefore, for C++ compiler vendors to also include a container
class library. You ll note that the vector is so useful that it was
introduced in its simplest form early in Volume 1 of this book.
Like many other early C++ libraries, early container class
libraries followed Smalltalk s object-based hierarchy, which worked well
for Smalltalk, but turned out to be awkward and difficult to use in C++.
Another approach was required.
The C++ approach to containers is based on templates. The
containers in the Standard C++ library represent a broad range of data
structures designed to work well with the standard algorithms and to meet
common software development needs.
Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |