我不知道如何搜索,因为Google似乎在搜索中忽略了::
。
我的伪代码行如下:
(在此情况下,玩家定义为:Player *player
)
if ( player == ::player )
我的意思是,如果var player
是player
类型。但这对我来说没有意义,因为编译器应该知道它是什么类型。
那么
::player
在这里是什么意思?
答案 0 :(得分:3)
我没有足够的代表发表评论。所以把它变成了一个完整的答案。
通常将::
运算符用作Scope resolution operator。
在您的示例中,由于不存在前缀的名称空间,因此取决于语言,它将引用全局player
从链接页面:
class A {
public:
static int i; // scope of A
};
namespace B {
int j = 2;
} // namespace B
int A::i = 4; // scope operator refers to the integer i declared in the class A
int x = B::j; // scope operator refers to the integer j declared in the namespace B
在IDA中,引用全局player
对象可能是它自己的方式。
在您的示例中:
if ( player == ::player )
开发人员明确地强制将本地player
对象/变量与全局命名空间中的player
对象/变量进行比较。
这是一个可能有用的simple online demo。 avar
基本变量可以是更复杂的对象,类或函数,而不是int。