pthreads and C++

后端 未结 2 990
既然无缘
既然无缘 2021-01-23 15:12

I am playing with C++ and pthreads and so far so good. I can access a class member function if it\'s static and I\'ve read that I can access a normal class member functions if I

2条回答
  •  迷失自我
    2021-01-23 15:32

    Pass a struct pointer.

    struct Arg {
      MyClass* _this;
      int      another_arg;
    };
    
    ...
    
    Arg* arg = new Arg;
    arg->_this = this;
    arg->another_arg = 12;
    pthread_create(..., arg);
    ...
    delete arg;
    

提交回复
热议问题