What does "::" mean?
I've seen ::
in some d开发者_Python百科ocumentations, e.g., xn::Generator::StartGenerating()
, and was wondering what it exactly signified?
It's the scope resolution operator in C++.
http://en.wikipedia.org/wiki/Scope_resolution_operator
See also: whats the difference between dot operator and scope resolution operator.
In C++, that's scoping names so that it can tell what you're talking about. Namespace (like std::cout) and class member definitions (like MyClass::MyMethod) come to mind.
In C++ at least, it refers to some sort of scope resolution. This could be a namespace (for example StartGenerating
is a function within the namespace Generator
), or it could be a class (for example StartGenerating
is a static function in the class Generator
)
Either way, it narrows the scope in which C++ will search for an identifier.
To add to the answers already here, after doing a quick google for "Double colon notation" I came across the following for PHP:
In short, it’s used to access Static or Constant members of a class
Source: http://www.whypad.com/posts/php-using-the-double-colon/500/
There's a brief discussion here on Stack Overflow also on the differences between the double colon and and arrow operators.
精彩评论