C ++ | scope operator "::"

effect:

  When the global variable name and local variable names are the same, the same name in the local variable effect global variable domain

usage:

  Prepend "::"

example:

#include<iostream>
using namespace std;

int  was = 1 ;
int main () {
     int  was ;
    was = 25 ;
    
    COUT << " local variable var: " << var << endl;
    cout << " global variables var: " << :: var << endl;
}

 

Guess you like

Origin www.cnblogs.com/jj81/p/11113113.html