class classe (){
public:
int key;
static void *funct(void *context){
printf("Output: %d, ", key);
}
void Go(){
classe c = static_cast<this>(context); //<- This doesn't work, Context of this-> goes here
pthread_create(&t, NULL, &classe::funct, c);
}
};
int main(){
classe c;
c.key = 15;
c.Go();
c.key = 18;
c.Go();
}
输出应该是Output: 15, Output: 18,
,事情是获取this
抛出错误的上下文。
有人知道如何解决这个问题吗?