在我的类中,有一个方法必须在另一个线程中调用它自己的另一个方法。编译器在std::thread th(run);行中产生此错误
错误 C3867:“Timer::run”:非标准语法;使用“&”创建指向成员的指针
void Timer::start()
{
std::thread th(run);
th.detach();
}
void Timer::run()
{
...
}
run 方法的实现对错误没有影响。
在我的类中,有一个方法必须在另一个线程中调用它自己的另一个方法。编译器在std::thread th(run);行中产生此错误
错误 C3867:“Timer::run”:非标准语法;使用“&”创建指向成员的指针
void Timer::start()
{
std::thread th(run);
th.detach();
}
void Timer::run()
{
...
}
run 方法的实现对错误没有影响。
在线程构造函数中,您需要将参数传递给函数,并且类函数有一个隐式参数 - 实际的类对象,因此编写
ZY 我首先只在 g++ 中检查过