title: How can I call a non-static member function of a class from a static member function of another class?
body: <p>I have a class with a static function (it must be static) that must call some registered member functions of instances of other classes:</p>
  <pre><code>class MyCalledClass
  {
      MyCallerClass&amp; caller;
      void functionToCall();
      void register()
      {
          caller.setFunctionToCall(&amp;MyCalledClass::functionToCall);
      }
      MyCalledClass(MyCallerClass&amp; mcc,...):caller{mcc}
      {
          register();
      }
  }
  
  class MyCallerClass
  {
      static void (MyCalledClass::*pointerToMember)();
      
      static void call()
      {
          *pointerToMember();
      }
  
      void setFunctionToCall(void (MyCalledClass::*pt)())
      {
          pointerToMember = pt;
      }
  }
  /*...*/
  MyCallerClass caller{...};
  MyCalledClass called{caller,...};
  </code></pre>
  <p>Why does the compiler says &quot;invalid use of unary '<em>' on pointer to member&quot; on the <em>pointerToMember() call in MyCallerClass::call?
  Setting pointerToMember as non-static is not allowed because it is used inside a static member function.
  Removing the '</em>' operator I get the error &quot;must use '.</em>' or '-&gt;*' to call pointer-to-member function in 'MyCallerClass::pointerToMember (...)', so I guess a reference is missing, but I don't understand which one.
  What kind of reference is missing?</p>