0
4

2 回答 2

0

因为workerFunc是成员函数,所以你必须将它绑定到线程。

boost::thread workerThread(&Base::workerFunc, this);
于 2013-03-06T15:41:11.753 回答
0

The cause of the error is that to take the address of the member function you need to say &Base::workerFunc

Once you fix that you'll get another error, which is that a non-static member function can't be called without an object, so you need to pass an object (or pointer to an object) to the thread constructor:

boost::thread workerThread(&Base::workerFunc, this);

This tells the thread object to create a new thread and then run this->workerFunc(), so that should work now.

If the function had arguments you would pass them after the this parameter:

boost::thread workerThread(&Base::workerFunc, this, arg1, arg2);
于 2013-03-06T15:52:14.063 回答