title: Multi-threading with classes in C++
body: <p>I have a problem with threads in C++. I want to create threads consisting of class member method with a specific object assigned. What is more, an object of another user-defined class is passed to that method. Please find the code below:</p>
  
  <pre><code>Grid an_chan(NX, NY, xmax, ymax);
  an_chan.calc_paraFlow(anode);
  
  Grid *ptr_grid = &amp;an_chan;    
  
  Variable T(Tin, Tinit, lambda_m, rho_m, Cp_m);
  Variable *ptr_T = &amp;T;
  
  std::thread first (&amp;Variable::initialize, ptr_T, ptr_grid);
  
  first.join();
  </code></pre>
  
  <p>Here is the initialize method prototype:</p>
  
  <pre><code>void Variable::initialize(Grid&amp; grid_obj)
  </code></pre>
  
  <p>Before I tried to add the thread, everything worked just right.</p>
  
  <p>I am just wondering if this is not a compiler issue? Maybe something is wrong with my code I can not notice? Any possible fixes? 
  Below I included the error returned by the compiler. As you can see I am using TDM GCC 5.1.0. I was using it with threads before and everything was working quite ok.</p>
  
  <blockquote>
    <p>In file included from C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/thread:39:0,
                     from main.cpp:13:
    C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/functional: In instantiation of 'struct std::_Bind_simple(chal::Variable, chal::Grid)>':
    C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/thread:142:59:   required from 'std::thread::thread(_Callable&amp;&amp;, _Args&amp;&amp; ...) [with _Callable = void (chal::Variable::*)(chal::Grid&amp;); _Args = {chal::Variable&amp;, chal::Grid&amp;}]'
    main.cpp:45:61:   required from here
    C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/functional:1505:61: error: no type named 'type' in 'class std::result_of(chal::Variable, chal::Grid)>'
           typedef typename result_of&lt;_Callable(_Args...)>::type result_type;
                                                                 ^
    C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/functional:1526:9: error: no type named 'type' in 'class std::result_of(chal::Variable, chal::Grid)>'
             _M_invoke(_Index_tuple&lt;_Indices...>)</p>
  </blockquote>