Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It’s possible to understand the concept of a “stack” (a data structure into which we insert items at the top and retrieve those items in last-in, first-out order) independent of the type of the items being placed in the stack. However, to instantiate a stack, a data type must be specified. This creates a wonderful opportunity for software reusability. We need the means for describing the notion of a stack generically and instantiating classes that are type-specific versions of this generic stack class. C++ provides this capability through class templates.
Software Engineering Observation 14.2
|
| Class templates encourage software reusability by enabling type-specific versions of generic classes to be instantiated. |