C++: Creating new thread using pthread_create, to run a class member function

前端 未结 4 1116
面向向阳花
面向向阳花 2020-12-22 04:53

I have the following class:

class A
{
    private:
        int starter()
        {
             //TO_DO: pthread_create()
        }

        void* threadStar         


        
4条回答
  •  独厮守ぢ
    2020-12-22 05:06

    Declare the threadStartRountine() as static:

    static void* threadStartRoutine( void *pThis );
    

    Otherwise, the type of threadStartRoutine() is:

    void* (A::*)(void*)
    

    which is not the type of function pointer that pthread_create() requires.

提交回复
热议问题