O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

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

10.8. Constant Expression Parameters

Up to now we have shown you only template classes that instantiate class types. It's also possible to create template classes with constant expression parameters. These parameters help build generic objects and define their operations at compile time. Let's find out how this form of template instantiation works and see an example of its use.

The format for constant expression parameters is a variant of the template class format you've already seen (page 414).

template <class TYPE1, class TYPE2, Type name1, Type nameN> 
class Class_name { . . . };

Constant expression parameters (Type nameN pairs) are similar to function signature arguments, except that you must instantiate them with expressions that evaluate ...

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