title: Static function access to class member
body: <p>Class Header:</p>
  
  <pre><code>#ifndef _APP_H_
  #define _APP_H_
  
  #include "glut.h"
  #include "Declare.h"
  
  
  class App {
  private:
      static float angle; 
  
  public:
  
      App();
      int OnExecute();
      void OnLoop();
      static void OnRender();
      bool OnInit();
      void OnCleanup();
      static void OnResize(int w, int h);
  
  
  };
  
  
  #endif
  </code></pre>
  
  <p>My definition of OnRender is</p>
  
  <pre><code>#include "App.h"
  
  App::App() {
      angle = 0.0f;
  }
  
  void App::OnRender() {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glLoadIdentity();
  
      gluLookAt( 0.0f, 0.0f, 10.0f,
                 0.0f, 0.0f, 0.0f,
                 0.0f, 1.0f, 0.0f);
      glRotatef(angle, 0.0f, 1.0f, 0.0f);
  
      glBegin(GL_TRIANGLES);
          glVertex3f(-2.0f,-2.0f,0.0f);
          glVertex3f(2.0f,0.0f,0.0f);
          glVertex3f(0.0f,2.0f,0.0f);
      glEnd();
  
      angle+=0.1f;
  
      glutSwapBuffers();
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>1&gt;App.obj : error LNK2001: unresolved external symbol "private: static float App::angle" (?angle@App@@0MA)
  1&gt;App_OnRender.obj : error LNK2019: unresolved external symbol "private: static float App::angle" (?angle@App@@0MA) referenced in function "public: static void __cdecl App::OnRender(void)" (?OnRender@App@@SAXXZ)
  </code></pre>
  
  <p>Something to do with how I am referencing the static variable inside the static function.  If I don't declare angle as <code>static float angle</code> then I certainly can't access it via <code>static void OnRender()</code>.  I have to add more details.  If I don't declare it as static, I get this error <code>illegal reference to non-static member App::angle</code></p>