| title | Template ref classes (C++/CX) | Microsoft Docs | |
|---|---|---|
| ms.custom | ||
| ms.date | 01/22/2017 | |
| ms.technology | cpp-windows | |
| ms.topic | language-reference | |
| ms.assetid | a24d5f45-8dbb-4540-958f-c76c90d8ed93 | |
| author | ghogen | |
| ms.author | ghogen | |
| ms.workload |
|
C++ templates are not published to metadata and therefore cannot have public or protected accessibility in your program. You can, of course, use standard C++ templates internally in your program. In addition, you can define a private ref class as a template and you can declare an explicitly specialized template ref class as a private member in a public ref class.
The following example shows how to declare a private ref class as a template, and also how to declare a standard C++ template and how declare them both as members in a public ref class. Note that the standard C++ template can be specialized by a Windows Runtime type, in this case a Platform::String^.
[!code-cppcx_templates#01]
Type System (C++/CX)
Visual C++ Language Reference
Namespaces Reference