static thread function access non-static class member in C++
- by user397390
Class Test{
int value;
static void* thread_func(void* args){
value++;
}
void newthread(){
pthread_create(&thread_func,...);
}
}
I'm trying to create a thread in Class Test. Therefore compiler forces me to make thread_func static. However I cannot access the non-static member "value" anymore. It says:
invalid use of member 'Class::value' in static member function
Is there a way around it?