title: Undefined reference to static variable
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/272900/c-undefined-reference-to-static-class-member">C++: undefined reference to static class member</a>  </p>
  </blockquote>
  
  
  
  <p>I'm using MinGW. Why static variable is not working  </p>
  
  <pre><code>[Linker error] undefined reference to `A::i' 
  
  #include &lt;windows.h&gt;
  
      class A { 
          public:     
          static int i;
          static int init(){
  
              i = 1;  
  
          }
  
      };
  
  int WINAPI WinMain (HINSTANCE hThisInstance,
                      HINSTANCE hPrevInstance,
                      LPSTR lpszArgument,
                      int nFunsterStil){
      A::i = 0;
      A::init();
  
      return 0;
  }
  </code></pre>