title: Call member function of an object using pthread
body: <p>How can I call the <code>thread_ready_function</code> into a thread as commented, using pthread ? I need to call it with the class object (In the real world the function uses attributes previously set). </p>
  
  <p><strong>MWE</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;pthread.h&gt;
  
  
  class ClassA
   {
  public:
  
       void * thread_ready_function(void *arg)
       {
           std::cout&lt;&lt;"From the thread"&lt;&lt;std::endl;
  
           pthread_exit((void*)NULL);
       }
   };
  
   class ClassB
   {
       ClassA *my_A_object;
  public:
       void test(){
           my_A_object = new ClassA();
  
           my_A_object-&gt;thread_ready_function(NULL);
  
           // my_A_object-&gt;thread_ready_function(NULL);
           //  ^
           //  I want to make that call into a thread.
  
           /* Thread */
  /*
           pthread_t th;
           void * th_rtn_val;
  
           pthread_create(&amp;th, NULL, my_A_object.thread_ready_function, NULL);
           pthread_join(th, &amp;th_rtn_val);
  */
       }
   };
  
  int main()
  {
      ClassB *my_B_object = new ClassB();
      my_B_object-&gt;test();
  
      return 0;
  }
  </code></pre>