Home › C++ Tutorial › C++ scope
C++ scope
Where names are visible.
Locals live inside their braces. Globals are visible everywhere. ::x reaches the global when a local hides it.
Example code
#include <iostream>
using namespace std;
int x = 100;
int main() {
int x = 5;
cout << x << " " << ::x << endl;
return 0;
}