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.4. Specializing Template Classes

Template class specialization is similar to specializing template functions (page 400). Once you define a template class for a generic type, specialized versions for specific types are possible. There are two reasons why you specialize template classes.

  1. A template class generates compilation errors for a specific type or does not work properly, and a correct version for that type is necessary.

  2. A template class member function executes slowly for a specific type, and you need to improve performance with a different type-specific function.

There are a few rules you need to know when specializing template classes. First, the class definition for the specialized class must appear after the generic template class ...

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