c++ - How can I pass a class member function as a callback? -


i'm using api requires me pass function pointer callback. i'm trying use api class i'm getting compilation errors.

here did constructor:

m_credundencymanager->init(this->redundencymanagercallback); 

this doesn't compile - following error:

error 8 error c3867: 'cloggersinfra::redundencymanagercallback': function call missing argument list; use '&cloggersinfra::redundencymanagercallback' create pointer member

i tried suggestion use &cloggersinfra::redundencymanagercallback - didn't work me.

any suggestions/explanation this??

i'm using vs2008.

thanks!!

as showed init function accepts non-member function. this:

static void callback(int other_arg, void * this_pointer) {     cloggersinfra * self = static_cast<cloggersinfra*>(this_pointer);     self->redundencymanagercallback(other_arg); } 

and call init with

m_credundencymanager->init(&cloggersinfra::callback, this); 

that works because function pointer static member function not member function pointer , can handled pointer free function.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -