关于我在 C 语言中从未见过的特殊运算符的一些问题; 代码
我已经下载了Phoenix SDK June 2008(编译器工具),当我阅读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;
2 个问题: ref 关键字是什么? 那个符号^是什么? 它在做什么
protected:
virtual void
Execute
(
Phx::Unit ^ unit
) override;
};
override 也是 C++ 关键字吗? 它在我的 Visual Studio 中是这样着色的。 我很想玩一下这个框架,但是这个高级的C++现在确实是一个障碍。 谢谢。
I have downloaded the Phoenix SDK June 2008 (Tools for compilers) and when I'm reading the code of the Hello sample, I really feel lost.
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;
2 Questions : What's that ref keyword?
What is that sign ^ ? What is it doing
protected:
virtual void
Execute
(
Phx::Unit ^ unit
) override;
};
override is a C++ keyword too? It's colored as such in my Visual Studio.
I really want to play with this framework, but this advanced C++ is really an obstacle right now. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它不是标准 C++,而是 C++/CLI。
It's not standard C++, it's C++/CLI.
它是与 .NET 一起使用的 Microsoft 扩展。 插入符号指示存储在托管堆上的对象的句柄。 有关详细说明,请参阅 Bran Bray 的博客。
It's a Microsoft extension for use with .NET. The caret indicates a handle to an object stored on the managed heap. See Bran Bray's blog for a nice description.
它是 C++/CLI - 编写为在 .Net 框架下作为托管代码运行的代码,而不是常规 C++ 代码。
It is C++/CLI - code that is written to be run as managed code under the .Net framework, not regular C++ code.
这不是标准 C++ 的一部分。 它是 C++/CLI,这是一种 Microsoft 语言规范,旨在取代托管 C++:
插入符号在 C++/CLI 中相当于指针,如 Rob Walker 对 这个问题:
在此 博客文章。
That is not part of standard C++. It's C++/CLI, which is a Microsoft language specification designed to replace Managed C++:
The caret symbol is the C++/CLI equivalent of a pointer, as described in Rob Walker's answer to this question:
The usage of "ref class X" instead of the familiar "class X" is discussed in this blog post.