1.

In C++, Given Two Variables Of The Same Name, One Local And One Global, How Do I Access The Global Instance Within The Local Scope?

Answer»

Use the scope (::) operator. 

int X = 10

for(int x=0; x < ::x; x++) 

COUT << "LOOP # " << x << "n"; // This will loop 10 times 

}

Use the scope (::) operator. 

int x = 10; 

for(int x=0; x < ::x; x++) 

cout << "Loop # " << x << "n"; // This will loop 10 times 

}



Discussion

No Comment Found