title: Why should I not initialize static variable in header?
body: <p>So, let's say I have a header like this:</p>
  
  <pre><code>#ifndef BASECLASS_H
  #define BASECLASS_H
  
  class BaseClass
  {
      public:
          static int getX(){return x;}
      private:
          static int x;
  };
  
  int BaseClass::x = 10;
  
  #endif
  </code></pre>
  
  <p>I have heard many times that I should not initialise static variables inside a header, but rather in cpp. But as there are guards, there should be only one copy of <code>BaseClass::x</code>. So I kinda do not understand why I should put </p>
  
  <pre><code>int BaseClass::x = 10; 
  </code></pre>
  
  <p>in cpp.</p>