小编Ahm*_*eem的帖子

在c ++中实现线程

我正在尝试用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)

帮我处理这件事.

c++ multithreading

0
推荐指数
1
解决办法
218
查看次数

标签 统计

c++ ×1

multithreading ×1