title: Why should I initialize static class variables in C++?
body: <p>In C and C++ all static variables are initialized by default to ZERO.</p>
  
  <p>This is not the case of static class data members. Why is that?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int var;
  
  class MyClass
  {
  public:
      static int classVar;
  };
  int MyClass::classVar = 0;  // Why I have to init it here?
  
  int main(void)
  {
      cout &lt;&lt; ::var &lt;&lt; endl;          // this is initalized to ZERO by default
      static int var;
      cout &lt;&lt; var &lt;&lt; endl;            // and this also is initalized to Zero
      cout &lt;&lt; MyClass::classVar &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>