Question

While trying to use std::threads i found myself with this error.

error C2064: term does not evaluate to a function taking 1 arguments 
File: functional
Line:1152

After commenting out some lines and such i found that the error comes from the constructor.

I am also using irrlicht therefore the event variable.

Here is the declaration of the thread:

t1=new thread((&EventReceiver::KeyInput3),event);

The header of the function:

int EventReceiver::KeyInput3(const SEvent& event)

Tryed constructing it in various way but none worked. What should I do in order to get rid of the error?

Was it helpful?

Solution

I am guessing KeyInput is not a static member function, so you need to pass a pointer to an instance of EventReceiver first:

EventReceiver* p = ...;
std::thread t(&EventReceiver::KeyInput3, p, event);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top