title: C++ static bool variable
body: <p>I can't understand something that causes LNK2005 errors that I've encountered.
  Assume that you have a class A:</p>
  
  <p>File A.h:</p>
  
  <pre><code>    #ifndef A_H
      #define A_H
  
      class A{
      public:
          static foo(void);
      private:
          static bool m_someVar;
      };
  
      bool A::m_someVar = false;
  
      #endif
  </code></pre>
  
  <p>File A.cpp:</p>
  
  <pre><code>    #include "A.h"
  
      void A::foo(){
          m_someVar = true;
      }
  </code></pre>
  
  <p>The code above causes a LNK 2005 however the following code doesn't:</p>
  
  <p>File A.h:</p>
  
  <pre><code>    #ifndef A_H
      #define A_H
  
      class A{
      public:
          static foo(void);
      private:
          static bool m_someVar;
      };
  
      #endif
  </code></pre>
  
  <p>File A.cpp:</p>
  
  <pre><code>    #include "A.h"
  
      bool A::m_someVar = false;
  
      void A::foo(){
          m_someVar = true;
      }
  </code></pre>
  
  <p>Can someone explain why is this happening even though I have include guards? Should I also add #pragma once?</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: here's the compilation error:
  "error LNK2005: "private: static bool GameManager::m_isGameOver" (?m_isGameOver@GameManager@@0_NA) already defined in Execution.obj"</p>