我试图运行 boost::thread 一些带有回调的对象函数
在 A 类中有一个这样的函数:
void DoWork(int (*callback)(float))
{
float variable = 0.0f;
boost::this_thread::sleep(boost::posix_time::seconds(1));
int result = f(variable);
}
在主要:
int SomeCallback(float variable)
{
int result;
cout<<"Callback called"<<endl;
//Interpret variable
return result;
}
int main(){
A* file = new A();
boost::thread bt(&A::DoWork, file , &SomeCallback );
cout<<"Asyns func called"<<endl;
bt.join();
cout<<"main done"<<endl;
}
该行boost::thread bt(&A::DoWork, file , &SomeCallback );
导致链接器错误。我从本教程中获得的这个电话:http:
//antonym.org/2009/05/threading-with-boost---part-i-creating-threads.html。
错误是:
unresolved external symbol "public: void __thiscall A::DoWork(int (__cdecl*)(float))" (?DoWork@A@@QAEXP6AHM@Z@Z) referenced in function _main
这段代码有什么问题?