在C ++ / CLI中,帽子字符^做什么? [英] In C++/CLI, what does the hat character ^ do?

查看:271
本文介绍了在C ++ / CLI中,帽子字符^做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Ivor Horton的Beginning Visual C ++ 2008,并且它的许多CLR示例都有这个定义:

I was reading Ivor Horton's Beginning Visual C++ 2008 and many of its CLR examples have this definition for main:

int main(array<System::String ^> ^args)

到本书的开头找到第一个这样的实例,并解释它真正意味着什么,但是找不到一个。

I went back, page by page, to the beginning of the book to find the first such instance with an explanation what it really means, but couldn't find one.

很明显,这意味着与标准相同 int main(int argc,char * argv []),但我想知道什么时候和为什么 ^ 真的被使用,为什么它甚至存在(它做的事情指针 * 和引用& )?

Obviously it means the same as the standard int main(int argc, char *argv[]), but I'd like to know when and why that ^ is really used, and why it even exists (does it do something that pointers * and references & cannot represent)?

推荐答案

这是一个管理指针 - while *标记指向非托管对象的指针,^指向垃圾回收对象(由框架处理)。有关.NET中指针处理方式的详细信息,请参阅

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.

这篇关于在C ++ / CLI中,帽子字符^做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆