我想維護兩個函數線程在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