title: C++: Issues in creating threads; error C2672: 'std::invoke': no matching overloaded function found
body: <p>Before marking this as duplicate, I have already seen the other answers and they did not solve my issue.</p>
  
  <p>I have two classes as follows:</p>
  
  <p>A.cpp:</p>
  
  <pre><code>class A
  {
    public:
            A();
            int getValue()//just an example of a get method 
                 {
                       return value;
                 }
  
    private:
           int value;
            // a lot of variables
  
  }
  </code></pre>
  
  <p>B.cpp:</p>
  
  <pre><code>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(&amp;B::simulate, list[0]);
                   thread t2(&amp;B::simulate, list[1]);
  
                   t1.join();
                   t2.join();
               }
  
     private:
  
       vector&lt;A*&gt; list;
  
       void simulate(A* ptr)
         {
              int value = 0;
  
              cout &lt;&lt; "At first value is " &lt;&lt; value &lt;&lt; endl;
              weight = ptr-&gt;getValue();
              cout &lt;&lt; "Then it becomes " &lt;&lt; value &lt;&lt; endl;
         }
  }
  </code></pre>
  
  <p>And then I have a simple main.cpp:</p>
  
  <pre><code>  int main()
        {
            B* b = new B();
            b-&gt;addData("File1.txt");
            b-&gt;addData("File2.txt");
  
            b-&gt;run();
  
            return 0;
  
         }
  </code></pre>
  
  <p>I am trying to create two threads by calling the method run(). However, when I try to compile I get the following error:</p>
  
  <pre><code>  error C2672: 'std::invoke': no matching overloaded function found
  </code></pre>
  
  <p>I checked the other posts but nothing seemed to work for me. Any help would be appreciated.</p>
  
  <p>P.S: I am using the following includes:</p>
  
  <pre><code> #include &lt;thread&gt;
   #include &lt;iostream&gt;
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>using namespace std;
  </code></pre>
  
  <p>I am using other includes but they are irrelevant </p>