Inheritance
and composition provide a way to reuse object code. The
template
feature in C++ provides a way to reuse
source
code.
Although
C++ templates are a general-purpose programming tool, when they were introduced
in the language, they seemed to discourage the use of object-based
container-class hierarchies. Later versions of container-class libraries are
built exclusively with templates and are much easier for the programmer to use.
This
chapter begins with an introduction to containers and the way they are
implemented with templates, followed by examples of container classes and how
to use them.