title: Create thread inside class with function from same class
body: <p>I want to be able to define a class with some data members, and a function which has access to those data members, which are to be private.</p>
  
  <p>I then want a public function, which creates some threads, which operate on the data members of the class. I am having some trouble getting my code to compile.</p>
  
  <p>Don't worry about mutex or data protection, this isn't going to be a problem, since this is just some example code for testing.</p>
  
  <pre><code>class foo {
      public:
      void make_foo_func_threads();
  
      private:
      void foo_func();
  
      char private_data;
      std::vector&lt;std::thread&gt; some_threads;
  }
  
  void foo::foo_func() {
      while(1) {
          private_data = 'A';
      }
  }
  
  void foo::make_foo_func_thread() {
      for(...) some_threads.push_back(std::thread(foo_func));
      for(...) some_threads.join();
  }
  </code></pre>
  
  <p>The compiler is giving me the error:</p>
  
  <blockquote>
    <p>'no matching call to std::thread::thread()'</p>
  </blockquote>
  
  <p>Apparently there is 'no known conversion for argument 1 from <code>&lt;unresolved overloaded function type&gt;</code> to <code>void (foo::*&amp;&amp;)'</code>.</p>
  
  <p>Erm, yeah, I have no idea what that means apart from the compiler is having trouble understanding how to resolve foo_func - I think.</p>
  
  <p>How can I help the compiler understand what I am trying to do, so it won't bother me with any more errors. No doubt the code I have written is not legal, and if that is the case could someone explain why that is the case to me. Thanks!</p>