What is the meaning of :: while calling a method in mfc and c++?
我在我的项目中找到了一个类似的代码
1 | if(::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) != 0) |
或
1 2 3 4 5 6 7 | if(<Some Condition>) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } |
:的意义是什么?
代码与JNI相关。
是因为线程编程吗(我不知道)?
这是范围说明符。
这里有更多的信息。
C++ names can be used only in certain regions of a program. This area is called the"scope" of the name. Scope determines the"lifetime" of a name that does not denote an object of static extent. Scope also determines the visibility of a name, when class constructors and destructors are called, and when variables local to the scope are initialized. (For more information, see Constructors and Destructors.) There are five kinds of scope:
- Function scope
- File scope
- Class scope
- Prototype scope
阅读这些文章了解更多信息。
还有很多关于范围的教程。
A scope is a region of the program and broadly speaking there are three places, where variables can be declared ?
Inside a function or a block which is called local variables,
In the definition of function parameters which is called formal parameters.
Outside of all functions which is called global variables.
我应该指出,同样的规则也适用于函数。因此,如果函数是在(例如)