【发布时间】:2013-09-18 18:38:15
【问题描述】:
看看这两个代码。
下面的代码可以正常工作。
void someFunction () {
// Some unimportant stuff
}
MainM::MainM(QObject *parent) :
QObject(parent)
{
std::thread oUpdate (someFunction);
}
此代码抛出错误:
void MainM::someFunction () { //as a class member
}
MainM::MainM(QObject *parent) :
QObject(parent)
{
std::thread oUpdate (someFunction);
}
错误:
error: no matching function for call to 'std::thread::thread(<unresolved overloaded function type>)'
std::thread oUpdate (someFunction);
^
【问题讨论】:
-
Start thread with member function 的可能重复项 - 您是否尝试过搜索现有答案?
-
@JonathanWakely 是的,对不起。它不仅与 std::thread 相关,所以...
标签: c++ c++11 member-function-pointers stdthread