C++ :: Scope Resolution Operator

Classification
1. Global scope symbol (::name): used before the type name (class, class member, member function, variable, etc.), indicating that the scope is the global namespace
2. Class scope symbol (class::name) : Used to indicate that the scope of the specified type is specific to a certain class
3. Namespace scope symbol (namespace::name): Used to indicate that the scope of the specified type is specific to a certain namespace

:: Use

int count = 0;        // 全局(::)的 count

class A {
   
    
    
public:
    static int count; // 类 A 的 count(A::count)
};

int main() {
   
    
    
    ::count = 1;      // 设置全局的 count 的值为 1

Guess you like

Origin blog.csdn.net/it_xiangqiang/article/details/112978226