class SaidClass {
public:
void INIT();
void saidthread(void* parm);
};
void SaidClass::INIT()
{
_beginthread(saidthread,0,NULL);
}
void SaidClass:saidthread(void* parm);
{
printf("Said Class is working! \n");
}
How do i use _beginthread() inside a class without making the function static?
Ok, so how do i use _beginthread() inside a class without having to make the function i want the thread to use static, also the function that i wanna use for the thread is in the class.
Its like this:
Thanks
You can't pass a pointer to member function to _beginthread(). However, what you can do is pass a pointer to a static member function that uses the void * data you give to _beginthread() to call a normal member function. Ex:
class SaidClass { public: void INIT(); void saidthread(void); static void thunk(void * ptr) { reinterpret_cast<SaidClass *>(ptr)->saidthread(); }};void SaidClass::INIT() { _beginthread(&SaidClass::thunk,0,this);}void SaidClass::saidthread(void) { printf("Said Class is working! \n");}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement