title: Callback: function pointer as argument and passing an aditional agrument
body: <p>How to pass a function pointer as argument with an argument?</p>
  <pre><code>void A(){
      std::cout &lt;&lt; &quot;hello&quot; &lt;&lt; endl;
  }
  
  void B(void (*ptr)()){ // function pointer as agrument
      ptr(); // call back function &quot;ptr&quot; points.
  }
  
  void C(string name){
      std::cout &lt;&lt; &quot;hello&quot; &lt;&lt; name &lt;&lt; endl;
  }
  
  void D(void (*ptr2)(string name)){ // function pointer as agrument
      ptr2(name); // error 1
  }
  
  int main(){
      void (*p)() = A; // all good
      B(p); // is callback // all good
  
      void (*q)(string name) = C;
      D(q)(&quot;John Doe&quot;); // error 2
      return 0;
  };
  </code></pre>
  <p>errors:<br />
  1 - use of undeclared identifier 'name'<br />
  2 - called object type 'void' is not a function or function pointer</p>