O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Template Classes

Rather than make a collection of generic functions to process data types, it is usually more efficient to create a class that performs a given set of related operations on a data type. In the STL, for example, there are classes that provide abstractions of various containers.

Each class offers methods that are generic in their definition but can be specialized by the compiler to handle any kind of data. These are called template classes and are very powerful, and very easy to use, with some caveats, which you’ll read about along the way.

The class itself is then generic and can be used with any type. As with function templates, you denote the various type variations that you want to make available by a system of placeholders. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required