C++/CLI Object^%(脱字符百分号)声明是什么意思?
这显然是一个谷歌验证的术语,因为我无法让任何搜索引擎不丢弃“额外”字符。我也查看了 MSDN 中的 C++ 参考,但我似乎找不到 C++/CLI 参考,因为声明部分中没有任何内容。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
%
是 跟踪参考。它类似于本机引用 (
Object&
),但跟踪引用可以引用 CLR 对象,而本机引用则不能。这种区别是必要的,因为垃圾收集器可以移动 CLR 对象,因此 CLR 对象的内存地址可能会改变。^
是 句柄。这仅仅意味着它受到管理。请参阅 MSDN 以及这篇 SO 帖子 。%
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.它的意思是“通过引用传递”:
中的情况相同
C++或 C#
: C++/CLI 不区分 ref 和 out,它没有 C# 语言具有明确赋值检查功能,因此无需区分两者。 VB.NET 中的情况相同,ByRef 与 ByVal。
It means "pass by reference":
Same thing in C++:
or C#:
C++/CLI doesn't distinguish between ref and out, it does not have the definite assignment checking feature that the C# language has so no need to distinguish between the two. Same in VB.NET, ByRef vs ByVal.
本质上,它是
Object*&
的“托管”版本,相当于 C# 中引用类型的ref
或out
。Essentially, it's the "managed" version of
Object*&
, and equivalent toref
orout
on a reference type in C#.这是一个通过引用管理的指针。所以如果你有类似的东西:
在 C# 中它看起来像:
This is a managed pointer by reference. So if you had something like:
in C# it would look like:
这是 C++/CLI 跟踪参考。这有点像 C++ 引用,但指向托管对象。
This is a C++/CLI Tracking Reference. This is kind of like a C++ reference, but to a managed object.