In C++/CLI, what does the hat character ^ do? [duplicate]

巧了我就是萌 提交于 2019-11-26 13:22:48

It's a managed pointer - while * marks a pointer to an object that is unmanaged, ^ points to a garbage collected object (handled by the framework). Read this for more information about the way pointers are handled in .NET.

Ray Hidayat

Just to add to that, in C++/CLI, managed pointers are handled separately from normal pointers, so you even allocate them with a different keyword:

NativeObject* n = new NativeObject();
ManagedObject^ m = gcnew ManagedObject();

Managed and Native objects are two completely different things and you can't mix them (well, not easily).

See this for full discussion: http://msdn.microsoft.com/de-de/library/yk97tc08.aspx:

A handle to an object on the managed heap points to the "whole" object, and not to a member of the object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!