![]() |
Problem in Threads in C++.
Hello, I m facing problem while adding thread in my class. But if I add thread to my main function than it's working fine.
Code that is working fine is Code:
#include <cstdlib>Code:
cDqu.h:36: error: argument of type ‘void (cDequeue::)(void*)’ does not match ‘void* (*)(void*)’Code:
#include <cstdlib>Regards, Hardik |
Re: Problem in Threads in C++.
Hi,
U cannot pass a non static member function to pthread_create as non static member function includes an implicit "this" pointer. U can consider following two solutions depending on your requirements. 1. Declare funDequeue() as static function.(No this pointer in case of static functions) 2. Write a helper function(non member ) which takes object of class cDequeue as parameter and then calls function funDequeue(). ie void * helper(void * Obj) { cDequeue * ptr = (cDequeue *) Obj; ptr -> funDequeue(); } |
| All times are GMT +5.5. The time now is 23:30. |