我正在玩C++和pthreads,到目前为止一直很好.我可以访问一个类成员函数,如果它是静态的,我已经读过,如果我将"this"作为参数传递给pthread_create,我可以访问普通的类成员函数,因为c ++是这样做的.但我的问题是我想给该函数一个int,我不知道如何用pthread_create做多个参数.
传递结构指针.
struct Arg {
MyClass* _this;
int another_arg;
};
...
Arg* arg = new Arg;
arg->_this = this;
arg->another_arg = 12;
pthread_create(..., arg);
...
delete arg;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
433 次 |
| 最近记录: |