title: Class function pointer as parameter
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11260260/how-to-best-pass-methods-into-methods-of-the-same-class">How to best pass methods into methods of the same class</a>  </p>
  </blockquote>
  
  
  
  <p>I've never had problems passing a function pointer as parameter. This works:</p>
  
  <pre><code>void functionThatTakesFPTR(void(*function)(int), int someValue){ 
      function(someValue);
     }
  
  void printValue(int value){
      std::printf("%d",value);
  }
  
  int main(int argc, char** argv){
      functionThatTakesFPTR(&amp;printValue, 8);
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>However, passing object function doesn't</p>
  
  <pre><code>void MyClass::setter(float value){ }
  
  void MyClass::testFunction(void(*setterPtr)(float)){ }
  
  void MyClass::someFunc(){
       testFunction(&amp;(this-&gt;setter));
  }
  </code></pre>
  
  <p>To me this looks like passing the address of this instead of the function, and I'm a bit confused. Is it possible to do so? And is it possible to pass the function pointer of object of another class (of instance MyClass2) ?</p>
  
  <p>Edit: Error I'm getting is "class 'MyClass' has no member 'setter' ".</p>