title: LNK2001 error when accessing static variables C++
body: <p>I'm trying to use a static variable in my code when trying to use textures, however I keep getting this error:</p>
  
  <pre><code>1&gt;Platform.obj : error LNK2001: unresolved external symbol "private: static unsigned int Platform::tex_plat" (?tex_plat@Platform@@0IA)
  </code></pre>
  
  <p>I have initialised the variable properly in the cpp file, however I believe this error occurs when trying to access it in another method.</p>
  
  <p>.h</p>
  
  <pre><code>class Platform :
  public Object
  {
      public:
          Platform(void);
          ~Platform(void);
          Platform(GLfloat xCoordIn, GLfloat yCoordIn, GLfloat widthIn);
          void draw();
          static int loadTexture();
  
      private:
          static GLuint tex_plat;
  };
  </code></pre>
  
  <p>.cpp classes:
  This is where the variable is initialised</p>
  
  <pre><code>int Platform::loadTexture(){
   GLuint tex_plat = SOIL_load_OGL_texture(
              "platform.png",
              SOIL_LOAD_AUTO,
              SOIL_CREATE_NEW_ID,
              SOIL_FLAG_INVERT_Y
              );
  
      if( tex_plat &gt; 0 )
      {
          glEnable( GL_TEXTURE_2D );
          return tex_plat;
      }
      else{
          return 0;
      }
  }
  </code></pre>
  
  <p>I then wish to use the tex_plat value in this method:</p>
  
  <pre><code>void Platform::draw(){
      glBindTexture( GL_TEXTURE_2D, tex_plat );
      glColor3f(1.0,1.0,1.0);
      glBegin(GL_POLYGON);
      glVertex2f(xCoord,yCoord+1);//top left
      glVertex2f(xCoord+width,yCoord+1);//top right
      glVertex2f(xCoord+width,yCoord);//bottom right
      glVertex2f(xCoord,yCoord);//bottom left
      glEnd();
  }
  </code></pre>
  
  <p>could some one explain this error.</p>