title: How can I pass a C++ member function to a C API as a parameter
body: <p>In my C++ program, I need to call this c API:</p>
  
  <pre><code>GConn* gnet_conn_new (const gchar *hostname,
                        gint port,
                        GConnFunc func);
  </code></pre>
  
  <p>where GConnFunc is defined as:</p>
  
  <pre><code>void (*GConnFunc) (GConn *conn);
  </code></pre>
  
  <p>My question is if I have a C++ class and have a member function like:</p>
  
  <pre><code>Class A {
   public:
     A();
     void my_func (GConn* conn);
  }
  </code></pre>
  
  <p>In my <code>A::A()</code> Constructor, how can I pass <code>this-&gt;myfunc</code> to <code>gnet_conn_new</code> as the <code>GConnFunc</code> parameter?</p>
  
  <p>Thank you.</p>