Templates
C++ templates enable you to define a family of functions or classes that can operate on different types of information. The Microsoft implementation of C++ templates is based on the ISO/ANSI C++ Standard.
Use templates in situations that result in duplication of the same code for multiple types. For example, you can use function templates to create a set of functions that apply the same algorithm to different data types. You can also use class templates to develop a set of typesafe classes. Templates are sometimes a better solution than C macros and void pointers, and they are especially useful when working with collections (one of the main uses for templates in MFC) and smart pointers.
In This Section
Overview
Provides general information about templates, or parameterized types, in Visual C++.Specifications
Provides a specification for a template declaration.typename
Describes the typename keyword.Referencing Templates [C++ Language]
Provides a task showing how to reference templates in your code.Angle Bracket Placement
Describes how angle brackets are placed in templates.Differences from Other Implementations
Discusses Microsoft-specific implementations of templates.Name Resolution
Discusses the three types of names in template definitions.Class Templates
Describes how to use and work with class templates.Function Templates
Describes how to use and work with function templates.
Related Sections
ATL Reference
Provides reference material for the ATL Library, a set of template-based C++ classes that simplify the programming of COM objects.C++ Language Reference
Describes the C++ programming language as implemented in Microsoft C++.Generics and Templates
Discusses the differences between generics and templates.