c ++ std :: thread构造函数用法

时间:2013-07-04 08:18:43

标签: c++ multithreading std irrlicht

在尝试使用std :: threads时,我发现自己有这个错误。

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

在注释掉一些行后,我发现错误来自构造函数。

我也在使用irrlicht事件变量。

这是线程的声明:

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

函数的标题:

int EventReceiver::KeyInput3(const SEvent& event)

尝试以各种方式构建它但没有工作。 我该怎么办才能摆脱错误?

1 个答案:

答案 0 :(得分:3)

我猜KeyInput不是静态成员函数,因此您需要首先将指针传递给EventReceiver的实例:

EventReceiver* p = ...;
std::thread t(&EventReceiver::KeyInput3, p, event);
相关问题