0

when I try to create new thread inside my class i get an error in the functional header that says : Error 1 error C2064: term does not evaluate to a function taking 4 arguments c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional 1149 1 Puzzel-8

//////////////////////////////////////////////////////////// this is my calling to create the new thread :

thread s(&puzzle::new_thread, state, dir_downn, ini_0_position_i,     ini_0_position_j);
s.detach();

///////////////////////////////////////////////////// and this is the new_thread function :

enter code here

void puzzle::new_thread(int * state1[], int move_direction, int     ini_0_position_i, int ini_0_position_j)
{
    int **state2;
    state2 = new int*[puzzle_size];
    for (int i = 0; i < puzzle_size; i++)
    {
        state2[i] = new int[];
    }
    copy_array(state1, state2);
    path_increment(initial_0_position_j, initial_0_position_i, state2,     move_direction);
    goal(state2);``
    the_main(state2, ini_0_position_i, ini_0_position_j);

}

///////////////////////////////////////////// note : when I try to create a thread in the main() it works

cloud em
  • 21
  • 6

1 Answers1

0

Your problem, it appears, is related to the fact, that you're trying to invoke class method to serve as thread entry point. If you do this, first argument shall be this pointer, pointing to the object of the class

UPDATE

try something like

thread s(&puzzle::new_thread, &puzzle_obj, state, dir_downn, ini_0_position_i,     ini_0_position_j);

UPDATE

Good discussion here Start thread with member function

Community
  • 1
  • 1
Severin Pappadeux
  • 18,636
  • 3
  • 38
  • 64