CLI :
The common Language Infrastructure (Common Language Infrastructure) is an expert group set up by the ECMA (European Association of Computer manufacturers), combined with the ISO
Mark Development of an extensible language standard .
The purpose of C + +/CLI is to bring it to the CLI platform, so that C + + can perform the maximum capabilities on the CLI platform, rather than constraining C + + to the CLI platform (the CLI itself is
ISO standardized). Conversely, the original standard C + + capability has not diminished, and, through the standard extension in C + +/CLI,C + + has a series of
. NET features and dynamic programming capabilities . These extensions are not proprietary, but are presented in a standard way.
value type
[1] Common types
Built-in value types (basic data types), custom value types, enumeration types, and so on;
[2] description
Value types can be created directly in the stack memory using the stack semantics as in a C + + program or by using the type pointer * new in heap memory dynamic creation of value type pairs in
To create a value type managed object in managed heap memory by defining a handle to the value type ^. gcnew .
Reference type (ref type)
[1] Common types
Such as: Built-in reference type (object and string), pointer (trace handle tracking handle, internal pointer interior pointer, fixed pointer pinning
pointer), custom reference types, array types, boxed value types, delegates, interfaces, and so on.
[2] Description
Use the gcnew operator to create a type of managed object in managed heap memory by using the handle of the type ^(the " tracking pointer " Of the class object, and the pronunciation of "hat"). can also
The handle ^ points to a managed object of the same type that already exists. The system's garbage collector automatically tracks the usage state of the managed object through a handle ^, and the managed pair
The ability to automatically revoke and reclaim the managed memory occupied by managed objects when they are no longer in use can be done without the programmer's own management.
Attention:
The C + +/CLI extension provides both deterministic and non-deterministic destruction of managed object memory, enabling the use of delete to gcnew dynamically created types of managed objects
The use of a row undo, which also includes the memory used to destroy a managed array using delete[] , which is known as deterministic destruction , note thatdelete does not actually
There is a direct destruction of the managed object's memory, it simply calls the destructor of the type to handle ^ perform the cleanup work, and the garbage collector will be responsible for the final destruction and recycling of the
The memory of the Tube object ( non-deterministic destruction ). The destruction order is obviously particularly important when dealing with objects that represent a resource, such as files and network connections, so
Resources, it is best to use the manual removal method to ensure that memory is destroyed.
[3] Initialization
Initialize the handle of the type ^ to " empty ", using nullptr, such as:
String ^firstprompt =nullptr;
C + +/CLI managed C + + data type Introduction "2"