Template Classes with Several Parameters

In previous examples, I used a template class with one type parameter only, even though I mentioned that a template class can have several type parameters.

These parameters can be type parameters similar to the previous examples or even parameters that resemble conventional value parameters in functions. Multiple parameters and the mix of type parameters and expression parameters notably increase the flexibility of C++ templates. At the same time, they introduce additional syntactic complexities.

Several Type Parameters

Let us consider a template class with more than one type parameter. The names of these parameters should be used within the class for its data members, local variables, or method parameters. ...

Get Core C++ A Software Engineering Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.