Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Enables the use of C++ keywords as identifiers.



The __identifier keyword enables the use of C++ keywords as identifiers. The main purpose of this keyword is to allow managed classes to access and use external classes that may use a C++ keyword as an identifier. For more information on __identifier, see 22 __identifier Keyword.

Note   Use of the __identifier keyword for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.


In the following example, a C# class (called template) is created and assigned to pTemplate:

// identifier_template.cs
// compile with: /target:library
public class template
   public void Run()
// keyword__identifier.cpp
// compile with: /clr
#using <mscorlib.dll>
#using <identifier_template.dll>   // defines a C# class called template

int main()
   __identifier(template) *pTemplate = new __identifier(template)();
   return 0;

See Also

Managed Extensions for C++ Reference | C++ Keywords

© 2016 Microsoft