title: Should I declare a variable inside or outside the main function?
body: <p>In C++, it is advisable to declare global variables inside the main program, or outside it, before everything else? I mean, what is the difference between</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int variable;
  
  int main()
  {    //my program
       return 0;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main()
  {
       int variable;
       //my program
       return 0;
  }
  </code></pre>
  
  <p>In which case should I use which one?</p>