R
raxitsheth
Hello All...
I am using Posix Thread.
class Parent
{
public: virtual void* func(void *)=0;
};
class Child : public
{
void *func(void *);
};
void* Child :: func(void *) { //pring Msg}
int GlobalFunc(Parent * p)
{
void* (Parent::*func)= p->func;//p May Point to Child Object....!!!
pthread_t thread1;
pthread_create(&thread1,NULL,.......,NULL);// Here I want to Call
func of Any Derived Class of Parent
pthread_exit(0);
}
int main()
{
Child ch1;
GlobalFunc(&ch1);
return 1;
}
My Problem is at pthread_create......
in pthread_create i am Able to Call any Public function (Like C)
But I am not Able to compile the program when i am Calling any Function
of Any Class
using Function Pointer.
Error comes : cannot convert `void*(Parent ::*)(void*)' to
`void*(*)(void*)' for
argument `3' to `int pthread_create(pthread_t*, const
pthread_attr_t*,
void*(*)(void*), void*)'
i.e. pthread_create requires 3rd argument a Function pointer having Arg
and Ret type of void * , But I am Giving Function pointer which points
to Function of Parent type having Arg and Ret type void *
How to Solve the prob...
I think POSIX support only C,its not C++.......
Waiting for reply....
Thanks...
Regards
Raxit
I am using Posix Thread.
class Parent
{
public: virtual void* func(void *)=0;
};
class Child : public
{
void *func(void *);
};
void* Child :: func(void *) { //pring Msg}
int GlobalFunc(Parent * p)
{
void* (Parent::*func)= p->func;//p May Point to Child Object....!!!
pthread_t thread1;
pthread_create(&thread1,NULL,.......,NULL);// Here I want to Call
func of Any Derived Class of Parent
pthread_exit(0);
}
int main()
{
Child ch1;
GlobalFunc(&ch1);
return 1;
}
My Problem is at pthread_create......
in pthread_create i am Able to Call any Public function (Like C)
But I am not Able to compile the program when i am Calling any Function
of Any Class
using Function Pointer.
Error comes : cannot convert `void*(Parent ::*)(void*)' to
`void*(*)(void*)' for
argument `3' to `int pthread_create(pthread_t*, const
pthread_attr_t*,
void*(*)(void*), void*)'
i.e. pthread_create requires 3rd argument a Function pointer having Arg
and Ret type of void * , But I am Giving Function pointer which points
to Function of Parent type having Arg and Ret type void *
How to Solve the prob...
I think POSIX support only C,its not C++.......
Waiting for reply....
Thanks...
Regards
Raxit