我想维护两个函数线程在c + +(Visual Studio支持#包括库),当我运行没有参数的函数它运行良好,但与参数它弹出一个错误。 代码是:执行线程在c + +
void fun(char a[])
{}
int main()
{
char arr[4];
thread t1(fun);
//(Error 1 error C2198: 'void (__cdecl *)(int [])' : too few arguments for call)
thread t2(fun(arr));
//Error 1 error C2664: std::thread::thread(std::thread &&) throw()' :
//cannot convert parameter 1 from'void' to 'std::thread &&'
//Second Error is 2 IntelliSense: no instance of constructor
// "std::thread::thread" matches the argument list argument types are: (void
return 0;
}
帮我处理这个。
你应该检查如何正确传递参数。 http://en.cppreference.com/w/cpp/thread/thread/thread – inf