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

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

问题描述

我正在阅读 Ivor Horton 的 Beginning Visual C++ 2008 并且其中的许多 CLR 示例都对 main 有以下定义:

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)?

推荐答案

这是一个托管指针 - 而 * 标记指向非托管对象的指针,^ 指向垃圾收集对象(由框架处理).阅读this,了解有关在 .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天全站免登陆