小编Mos*_*zic的帖子

C++:创建线程的问题;错误 C2672:“std::invoke”:找不到匹配的重载函数

在将其标记为重复之前,我已经看到了其他答案,但它们没有解决我的问题。

我有两个类如下:

A.cpp:

class A
{
  public:
          A();
          int getValue()//just an example of a get method 
               {
                     return value;
               }

  private:
         int value;
          // a lot of variables

}
Run Code Online (Sandbox Code Playgroud)

B.cpp:

class B
{ 
     public: 
            B();
            void addData(string fileName)
              {
                  A* a = new A();

                  //reads the file with the fileName and does alot of stuff
                 //after calculation is over it adds the object to the vector
                list.push_back(a);

              }

           void run()
             {
                 thread t1(&B::simulate, list[0]);
                 thread t2(&B::simulate, list[1]);

                 t1.join();
                 t2.join();
             } …
Run Code Online (Sandbox Code Playgroud)

c++ multithreading compiler-errors visual-studio

6
推荐指数
1
解决办法
5262
查看次数