title: return value for a static variable
body: <p>I'm trying to use a static variable as a counter for the number of times a function has been called. Essentially, I'm having function A call function B a number of times, and I want function B to return that value to function A so it can be displayed. An example of my test code is below(here main is function A and showStat is function B). As of now the output is 012340; the desired output is 012344. Thanks in advance.</p>
  
  <pre><code>int showStat()
  {
  
      static int statNum;
      cout&lt;&lt;statNum; //function check
      statNum++;
      return statNum;
  }
  
  
  int main()
  {
      int statNum;
  
      for( int i = 0; i &lt; 5 ; i++)
      {
      showStat(); 
      }
      cout&lt;&lt;statNum;
  
      return 0;
  }
  </code></pre>