'^'(Handle to Object on Managed Heap)-->似Unmanaged的 '*'
A handle to an object on the managed heap points to the "whole" object, and not to a member of the object.
In Visual C++ 2002 and Visual C++ 2003, __gc * was used to declare an object on the managed heap. The ^ replaces __gc * in the new syntax.
'%'(tracking reference) -->似Unmanaged的 '&'
A tracking reference is similar to a C++ reference, to specify that a variable is passed to a function by reference and to create an alternative name for an object.
// Unmanaged
Int32* ptr = new Int32; // usual pointer allocated on heap
Int32& nat = *ptr; // object on heap bind to native object
// Managed(CLI)
Int32^ mngd = gcnew Int32; // allocate on CLI heap
Int32% rr = *mngd; // object on CLI heap reference to gc-lvalue
Int32^% rr1 = mngd ; // tracking reference handle to reference object
沒有留言:
張貼留言