"::"是什么意思在C ++中意味着什么? [英] What does the "::" mean in C++?
问题描述
这个符号是什么意思?
AirlineTicket::AirlineTicket()
推荐答案
::是范围分辨率运算符-用于限定名称.在这种情况下,它用于将类 AirlineTicket
与构造函数 AirlineTicket()
分开,形成限定名称 AirlineTicket :: AirlineTicket()
:: is the scope resolution operator - used to qualify names. In this case it is used to separate the class AirlineTicket
from the constructor AirlineTicket()
, forming the qualified name AirlineTicket::AirlineTicket()
在需要明确说明所指内容时,可以使用此选项.一些样本:
You use this whenever you need to be explicit with regards to what you're referring to. Some samples:
namespace foo {
class bar;
}
class bar;
using namespace foo;
现在,您已经使用示波器分辨率运算符来引用特定的条形.
Now you have to use the scope resolution operator to refer to a specific bar.
:: foo :: bar
是完全限定的名称.
:: bar
是另一个完全限定的名称.( ::
首先表示全局名称空间")
::bar
is another fully qualified name. (::
first means "global namespace")
struct Base {
void foo();
};
struct Derived : Base {
void foo();
void bar() {
Derived::foo();
Base::foo();
}
};
这使用范围解析来选择特定版本的foo.
This uses scope resolution to select specific versions of foo.
这篇关于"::"是什么意思在C ++中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!