问题描述
今天我看到以下语法。谁能告诉我这是什么意思:
Today I saw the following syntax. Can anybody tell me the meaning of this:
System::ComponentModel::Container ^components;
我在Visual C ++这段代码,我用了一个向导来创建服务后。
I got this code in Visual C++, after I used a wizard to create a service.
推荐答案
的 ^
操作符(不与二进制XOR运算符混淆)是具体到C ++ / CLI。
The ^
operator (not to be confused with the binary XOR operator) is specific to C++/CLI.
它用于一个手柄申报.NET托管对象。
It is used to declare a handle to a .NET managed object.
句柄是对对象的引用,它不同于传统的C ++指针,因为它允许垃圾收集对引用对象正确地运行,从而不需要手动对象删除。
A handle is a reference to the object which differs from traditional C++ pointers in the fact that it allows Garbage Collection to function correctly for the referenced object, making manual object deletion unnecessary.
此语法取代托管C ++扩展的 __ gc
指针。
This syntax supersedes the managed C++ extensions' __gc
pointers.
更多细节可以在这里找到: http://en.wikipedia.org/wiki/C%2B%2B/CLI
More details can be found here: http://en.wikipedia.org/wiki/C%2B%2B/CLI
这篇关于这个奇怪的语法的意思是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!