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();
}
Der Ausgang Output: 15, Output: 18,
zu einer Klasse Zeiger zuweisen soll, ist die Sache Zusammenhang mit this
wirft Fehler zu erhalten.Erster Kontext von „dieser“ in einer Klasse und theClass *
Jemand weiß, wie man das repariert?
Es muss keine freie Funktion sein, ein statisches Element funktioniert einwandfrei. – Josh
Danke, aktualisiert – Attila