我正在尝试用c ++中的线程维护两个函数(Visual Studio支持#include库),当我运行没有参数的函数时它运行正常,但是带参数会弹出错误.代码是:
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;
}
Run Code Online (Sandbox Code Playgroud)
帮我处理这件事.