title: Static variables in member functions
body: <p>Can someone please explain how static variables in member functions work in C++. </p>
  
  <p>Given the following class:</p>
  
  <pre><code>class A {
     void foo() {
        static int i;
        i++;
     }
  }
  </code></pre>
  
  <p>If I declare multiple instances of <code>A</code>, does calling <code>foo()</code> on one instance increment the static variable <code>i</code> on all instances? Or only the one it was called on?</p>
  
  <p>I assumed that each instance would have its own copy of <code>i</code>, but stepping through some code I have seems to indicate otherwise.</p>