title: How can I use local variable in another scope in C++?
body: <p>I want to access a local variable of main function in another scope.<br>
  My goal is to print 20 in <code>cout</code>.<br>
  How can I do this?<br>
  How is it possible in C++?</p>
  
  <pre><code>int var = 10;
  
  int main(int argc, char *argv[])
  {
      int var = 20; // this var
      {
          int var = 40;
          cout &lt;&lt; ::var; // I want to print `var` variable in main scope.
                         // But this command print global variable.
      }
  
      return 0;
  }
  </code></pre>