::GetWindowText(hWnd,buff,256);
这前面的::是什么意思啊,请解答一下吧。谢谢啊!

解决方案 »

  1.   

    ::表示全局,因为CWnd类中定义了GetWindowText成员函数,在类中如果直接写GetWindowText表示调用类的成员函数,加::之后表示调用API。
      

  2.   

    表示全局名字空间。比如:
    std::XXX()表示调用std名字空间里面的XXX方法
      

  3.   

    Scope Resolution Operator: ::See Also
    C++ Operators | Operator Precedence and Associativity | Namespaces | Names and Qualified Names
    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.Example
    // expre_ScopeResolutionOperator.cpp
    // compile with: /EHsc
    // Demonstrate scope resolution operator
    #include <iostream>using namespace std;int amount = 123;             // A global variableint main() {
       int amount = 456;          // A local variable
       cout  << ::amount << endl  // Print the global variable
             << amount << endl;   // Print the local variable
    }
    The example above has two variables named amount. The first is global and contains the value 123. The second is local to the main function. The scope resolution operator tells the compiler to use the global amount instead of the local one.