:: access global variables

:: one yuan scope resolution operator, when the same name as a local variable and the global variable can be used to access the global variables.

#include<iostream>
using namespace std;

int i{ 10 };
int main()
{
    int i{ 11 };
    cout << i << endl; //11
    cout << ::i << endl; //10

    return 0;
}

 

Guess you like

Origin www.cnblogs.com/xixixing/p/12032306.html