关于我在C++代码中从未见过的特殊运算符的一些问题

tot*_*oto 3 c++ syntax c++-cli

我已经下载了2008年6月的Phoenix SDK(编译器工具),当我正在阅读Hello示例的代码时,我真的感到迷茫.

public
ref class Hello
{
//--------------------------------------------------------------------------
//
// Description:
//
//    Class Variables.
//
// Remarks:
//
//    A normal compiler would have more flexible means for holding
//    on to all this information, but in our case it's simplest (if
//    somewhat inelegant) if we just keep references to all the
//    structures we'll need to access as classstatic variables.
//
//--------------------------------------------------------------------------

static Phx::ModuleUnit                 ^ module;
static Phx::Targets::Runtimes::Runtime ^ runtime;
static Phx::Targets::Architectures::Architecture       ^ architecture;
static Phx::Lifetime                   ^ lifetime;
static Phx::Types::Table               ^ typeTable;
static Phx::Symbols::Table                ^ symbolTable;
static Phx::Phases::PhaseConfiguration        ^ phaseConfiguration;
Run Code Online (Sandbox Code Playgroud)

2个问题:ref关键字是什么?那个标志是什么^?这是做什么的

保护:

  virtual void
  Execute
  (
     Phx::Unit ^ unit
  ) override;
Run Code Online (Sandbox Code Playgroud)

};

override也是一个C++关键字?它在我的Visual Studio中就这样着色了.我真的很想玩这个框架,但是这个先进的C++现在确实是一个障碍.谢谢.

Kla*_*aim 12

它不是标准的C++,而是C++/CLI.

  • 它们不是增强功能.这是一种单独的语言.它不是C++.微软并未声称它是C++.C++/CLI在技术上是一个完全不同的野兽. (6认同)
  • 我想这就是为什么Sun几年前起诉微软,以防止这种"增强" (3认同)

Mr *_*ooz 5

它是用于.NET的Microsoft扩展.插入符表示存储在托管堆上的对象的句柄.请参阅Bran Bray的博客,以获得精彩的描述.


180*_*ION 5

它是C++/CLI - 编写为在.Net框架下作为托管代码运行的代码,而不是常规C++代码.

  • ref - 此类是引用类型,它在托管堆中分配并将被垃圾回收
  • ^ - 此变量是托管实例的句柄
  • override - 此方法重写基类实现