title: C++ static pointer to function
body: <p>I would like to have a private static pointer to a function in my class. Basically, it would look like this:</p>
  
  <pre><code>//file.h
  class X {
  private:
      static int (*staticFunc)(const X&amp;);
      ...
  public:
      void f();
  
  };
  
  
  //file.cpp
  void X::f()
  {
      staticFunc(*this);
  }
  </code></pre>
  
  <p>This gives me an "unresolved external symbol" error. I know that static members must be initialized in the .cpp too, I've tried this:</p>
  
  <pre><code>int (X::*staticFunc)(const X&amp;) = NULL;
  </code></pre>
  
  <p>but this gives me an "initializing a function" error. It gives me an uglier error if I try to initialize it with an existing function. Without "= NULL", I get the same error.</p>
  
  <p>Thanks.</p>