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
のコンテキストがエラーをスロー取得することです。は「この」内部クラスのコンテキストを取得とするtheClass *
誰かがこれを修正する方法を知っていますか?
フリー関数である必要はありませんが、静的メンバーはうまく動作します。 – Josh
ありがとうございました – Attila