title: Strange behavior of static global variable
body: <p>I know that this program is not using the static variable in an appropriate way, but it shows how to reproduce a behavior I have seen :</p>
  
  <p><strong>Main.cpp :</strong></p>
  
  <pre><code>int main(){
      MyObject* p = new MyObject();
      Header::i = 5;
  
      printf("i %i\n", Header::i);
      p-&gt;update();
  
      return 0;
  }
  </code></pre>
  
  <p><strong>MyObject.cpp :</strong></p>
  
  <pre><code>MyObject::MyObject(){
  }
  
  void MyObject::update(){
      printf("i %i\n", Header::i);
  }
  </code></pre>
  
  <p><strong>Extern.h :</strong></p>
  
  <pre><code>namespace Header {
      static int i;
  };
  </code></pre>
  
  <p>The output I get is :</p>
  
  <pre><code>i : 5
  i : 0
  </code></pre>
  
  <p>Why don't I get <code>5</code> for both outputs ? Where does this <code>0</code>come from ?
  Could you explain how static variables work ?</p>