title: Function Pointer to a non-static member function?
body: <p>Is it possible to use a function pointer to point at a non-static member function? I would like to point at a member function that uses non-static objects and variables from the class...static member functions cannot do this...</p>
  
  <p>I have a member function that points at one of four static member functions. The problem is that the data to be used by each of the four member functions is non-static so the static member functions will not access them...</p>
  
  <p>Can I point at non-static member functions? </p>
  
  <p>Also, the class instance is a pointer...here is my code:</p>
  
  <pre><code>class CRoutine{
  int m_index;
      ...
          BOOL (*CallRoutine(char opcode))(DWORD, float, float, float);
          static BOOL Update(DWORD, float, float, float);
          static BOOL Transition(DWORD, float, float, float);
          static BOOL Revert(DWORD, float, float, float);
          static BOOL Sequence(DWORD, float, float, float);
      ...
      };
      BOOL (*CRoutine::CallRoutine(char opcode))(DWORD, float, float, float)
      {   
          switch ( opcode )
          {
          case 0:
              return &amp;CRoutine::Update;
          case 1:
              return &amp;CRoutine::Transition;
          case 2:
              return &amp;CRoutine::Revert;
          case 3:
              return &amp;CRoutine::Sequence;
          default:
              return &amp;CRoutine::Update;
          }
      }
      BOOL CRoutine::Update(DWORD AnimSetIndex, float time, float tTime, float shift)
      {
          MessageBox(NULL, L"Updating", L"Routine #1", MB_OK);
           CRoutine::m_index++; // Error thrown here...       
  return true;
      }
      BOOL CRoutine::Transition(DWORD AnimSetIndex, float time, float tTime, float shift)
      {
          MessageBox(NULL, L"Transitioning", L"Routine #2", MB_OK);
          return true;
      }
      BOOL CRoutine::Revert(DWORD AnimSetIndex, float time, float tTime, float shift)
      {
          MessageBox(NULL, L"Reverting", L"Routine #3", MB_OK);
          return true;
      }
      BOOL CRoutine::Sequence(DWORD AnimSetIndex, float time, float tTime, float shift)
      {
          MessageBox(NULL, L"Sequencing", L"Routine #4", MB_OK);
          return true;
      }
  </code></pre>
  
  <p>The error thrown above is:
  error C2597: illegal reference to non-static member 'CRoutine::m_index'</p>