O'Reilly logo

The C++ Programming Language, Fourth Edition by Bjarne Stroustrup

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

27. Templates and Hierarchies

Euclid’s and Beethoven’s Fifth; knowing just one of them marks you as semi-educated.

– Stan Kelley-Bootle

Introduction

Parameterization and Hierarchy

Generated Types; Template Conversions

Hierarchies of Class Templates

Templates as Interfaces

Template Parameters as Base Classes

Composing Data Structures; Linearizing Class Hierarchies

Advice

27.1. Introduction

Templates and derivation are mechanisms for building new types out of existing ones, for specifying interfaces, and generally for writing useful code that exploits various forms of commonality:

• A template class defines an interface. The template’s own implementation and those of its specializations can be accessed through that interface. The source ...

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