how use global variables instead of local in c++

C++
#include<iostream> 
  
using namespace std; 
  
int x;  // Global x 
  
int main() 
{ 
  int x = 10; // Local x 
  cout<<"Value of global x is "<<::x<<endl; 
  cout<<"Value of local x is "<<x;   
  getchar(); 
  return 0; 
} 

Source

Also in C++: