Search code examples
c++-cli

What does the C++/CLI Object^% (caret percent-sign) declaration mean?


This apparently is a Google-proof term since I can't get any search engines to not throw away the "extra" characters. I did also look on MSDN in the C++ reference but I can't seem to find the C++/CLI reference because there is nothing in the declarations section on it.


Solution

  • % is a tracking reference.

    It is similar to a native reference (Object&), but a tracking reference can reference a CLR object while a native reference cannot. The distinction is necessary because the garbage collector can move CLR objects around, so a CLR-object's memory address may change.

    The ^ is a handle. This simply means it is managed. See MSDN and also this SO post.