Chapter 10. Template Classes
You have seen the benefits of template functions with algorithms that are type independent. Now let's apply the concept of genericity to classes that manage type-independent data. Rather than manage separate classes bound to specific types, we create one generic class that provides the same set of behaviors for all types. Generic classes eliminate code duplication for different types and make library design easier and more manageable.
The C++ template mechanism supports the implementation of generic classes. This chapter shows you how to recognize genericity and how to design template classes. We look at template class definition and instantiation and how to specialize class definitions for efficiency and extensibility. ...
Get Navigating C++ and Object-Oriented Design now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.