title: C++ Using Class Method as a Function Pointer Type
body: <p>In a C lib, there is a function waiting a function pointer such that:</p>
  
  <pre><code>lasvm_kcache_t* lasvm_kcache_create(lasvm_kernel_t kernelfunc, void *closure)
  </code></pre>
  
  <p>where lasvm_kernel_t is defined as:</p>
  
  <pre><code>typedef double (*lasvm_kernel_t)(int i, int j, void* closure);
  </code></pre>
  
  <p>Now, if I send a method defined in a class to lasvm_kcache_create:</p>
  
  <pre><code>double cls_lasvm::kernel(int i, int j, void *kparam)
  ...
  lasvm_kcache_t *kcache=lasvm_kcache_create(&amp;kernel, NULL);
  </code></pre>
  
  <p>I get: "cannot convert ‘double (cls_lasvm::<em>)(int, int, void</em>)’ to ‘double (<em>)(int, int, void</em>)’"</p>
  
  <p>What should I do?</p>