vendredi 25 novembre 2016

This thread example doesn't work. Please help me why?

I am trying to compile the following example and I am getting an error. Below is the code :

class A {
    private:
     //variables

    public:
      A(int a,int b){
        //assign variables
      }
      void C(){
         // do something
      }
       int D(){
       // do something
       }
       void E(){
       }
  }; 
 int main(){
    A* temp = new A(a,b);
    temp->C;
    std::thread t;
    t(&A::D,A);
    t.join();
    temp->E;
    return 0;
 }

I get the following error when I compile the above code with pthread and std=c++11 flags. The following is the error message :

expected primary-expression before ‘)’ token
 t(&A::D,A);

Aucun commentaire:

Enregistrer un commentaire