The C++ standard allows compiler vendors to provide non-standard extensions to the language. Microsoft provides extensions to help you connect native C++ code to code that runs on the .NET Framework or the Universal Windows Platform (UWP). The .NET extensions are called C++/CLI and produce code that executes in the .NET managed execution environment that is called the Common Language Runtime (CLR). The UWP extensions are called C++/CX and they produce native machine code.
Note
For new applications, we recommend using C++/WinRT rather than C++/CX. C++/WinRT is a new, standard C++17 language projection for Windows Runtime APIs. We will continue to support C++/CX and WRL, but highly recommend that new applications use C++/WinRT. For more information, see C++/WinRT.
The C++/CX extensions are a subset of C++/CLI. Although the extension syntax is identical in most cases, the code that is generated depends on whether you specify the /ZW compiler option to target UWP, or the /clr option to target .NET. These switches are set automatically when you use Visual Studio to create a project.
Data Type Keywords
The language extensions include aggregate keywords, which consist of two tokens separated by white space. The tokens might have one meaning when they are used separately, and another meaning when they are used together. For example, the word "ref" is an ordinary identifier, and the word "class" is a keyword that declares a native class. But when these words are combined to form ref class, the resulting aggregate keyword declares an entity that is known as a runtime class.
The extensions also include context-sensitive keywords. A keyword is treated as context-sensitive depending on the kind of statement that contains it, and its placement in that statement. For example, the token "property" can be an identifier, or it can declare a special kind of public class member.
The following table lists keywords in the C++ language extension.
You can use the following keywords to qualify override behavior for derivation. Although the new keyword is not an extension of C++, it is listed here because it can be used in an additional context. Some specifiers are also valid for native programming. For more information, see How to: Declare Override Specifiers in Native Compilations (C++/CLI).
The following language constructs are implemented as templates, instead of as keywords. If you specify the /ZW compiler option, they are defined in the lang namespace. If you specify the /clr compiler option, they are defined in the cli namespace.