Not the actual code, but a representation:
I need to initiate a thread from one of my member functions and I do that this way:
return_val = pthread_create(&myThread, NULL, myStaticMethod, (void*)(this));
i) I pass this as an argument because static methods do not allow non-static members to be accessed, and since I have non-static methods and members to access inside the static method. Is this right? Or, are there any other alternatives?
myStaticMethod(void* args)
{
args->myPublicMethod(); //Is this legal and valid?
args->myPrivateMember; //Is this legal and valid?
}
I get an error saying void* is not a pointer to object type, and I think that args is to be typecast into an instance of type myClass.
But, how do I do that?