:: Scope Resolution Operator Example See AlsoRuns a parent class method from within a subclass method.SyntaxcClassName::cMethodResThe :: operator is used to execute a parent class method from within a subclass method. When you create a subclass, the subclass methods are automatically inherited from the parent class. The :: operator lets you execute the parent class method in the subclass method and then perform additional processing for the subclass method. The subclass definitions in the example demonstrate how the :: operator is used to execute the parent class method within a subclass method.For additional information about the :: scope resolution operator, see Chapter 3, Object-Oriented Programming in the Programmer's Guide.
应该是:调用全局函数。可以被调用的函数包括: GlobalSpace和用use namespace指定的名字空间内的函数。 这些函数不属于任何一个类如果没有使用use namespace指定可用的名字空间 那么就是指系统的GlobalSpace。::ReleaseCapture();就是调用全局的ReleaseCapture(); 即:不通过CWnd等类,直接调用Windows API
//from MSDNScope Resolution Operator: ::You can tell the compiler to use the global identifier rather than the local identifier by prefixing the identifier with ::, the scope resolution operator.:: identifier class-name :: identifier namespace :: identifier The identifier can be a variable or a function.If you have nested local scopes, the scope resolution operator does not provide access to identifiers in the next outermost scope. It provides access to only the global identifiers.
因为不同函数库的函数可能重名,这样你在程序前面使用
namespace 名字空间
然后调用的函数就是这个名字空间的函数了你也可以用这种方法临时指定
名字空间::函数名你看想不想再调用父类(或是静态)的函数阿???嗬嗬!其实不一样的另:windows程序有一个GlobalSpace的默认命名空间
CDialog类的函数OnCreate(),你可以在该类的某个函数里调用该类的另一个函数。
CDialog::OnCreate()
{
::OK();//该函数的类是CDialog,在这里可以缺省。
}
Example See AlsoRuns a parent class method from within a subclass method.SyntaxcClassName::cMethodResThe :: operator is used to execute a parent class method from within a subclass method. When you create a subclass, the subclass methods are automatically inherited from the parent class. The :: operator lets you execute the parent class method in the subclass method and then perform additional processing for the subclass method. The subclass definitions in the example demonstrate how the :: operator is used to execute the parent class method within a subclass method.For additional information about the :: scope resolution operator, see Chapter 3, Object-Oriented Programming in the Programmer's Guide.
GlobalSpace和用use namespace指定的名字空间内的函数。
这些函数不属于任何一个类如果没有使用use namespace指定可用的名字空间
那么就是指系统的GlobalSpace。::ReleaseCapture();就是调用全局的ReleaseCapture();
即:不通过CWnd等类,直接调用Windows API
楼上各位说得很正确。
但我认为xiepoor0只是在问直接使用::的意义。
即::前面什么都不加的时候
class-name :: identifier
namespace :: identifier
The identifier can be a variable or a function.If you have nested local scopes, the scope resolution operator does not provide access to identifiers in the next outermost scope. It provides access to only the global identifiers.