title: Functor to static member functions and type of static member function
body: <p>I was trying to assign a static member function to a functor as following:</p>
  
  <pre><code> class myClass
   {
     public: 
       static void (myClass::*fptr)();
       static void myFun()
       {
  
        }
   };
  
   (void (myClass::*)()) myClass::fptr = &amp;myClass::myFun; // doesn't work
  
   int main()
   {
     myClass obj;
     myClass::fptr = &amp;myClass::myFun;   // neither does this works
     return 0; 
   }
  </code></pre>
  
  <p>The above assignment is not working. </p>
  
  <p>At lest to check the type of the static member function(as I was not sure) I wrote the following statement in <code>main</code></p>
  
  <pre><code>myClass::fptr = &amp;myClass::myFun;
  </code></pre>
  
  <p>And the VS2010 intellisense displayed: </p>
  
  <pre><code>you can't assign a void ( * )() type to an entity of type void (myClass::*)()
  </code></pre>
  
  <p>I thought that type of static function should have been the latter(<code>void ( * )()</code>)</p>
  
  <p>I am also unable to figure out how to give definition for a <code>static functor</code> as it should be done for static data members.  </p>
  
  <p>I made the functor static because I want it to be independent of any instances of myClass.</p>
  
  <p>Can somebody please elaborate on this topic of <code>static functors</code> and also on the type of the static member functions(as to why it is <code>void(*)()</code> in this case). Is it even possible to have a function pointer to a static member function?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>I was able to work around this by using a <code>typedef</code>:</p>
  
  <pre><code>typedef void(*ptr)();
  class myClass
  {
   ....
   static ptr fptr;
  };
  
  ptr myClass::fptr = &amp; myClass::myFunc;
  </code></pre>
  
  <p>But still why is the type static member function <code>void( * )()</code> ?</p>