jeudi 5 décembre 2019

set value of a pointer into a calss member function

I got confused while passing pointer of a class member function to a variable. this is the body of my class:

class pjsuaMyClass
{
...
private:
 pj_bool_t default_mod_on_rx_request(pjsip_rx_data *rdata);
....
};

in my application there is a structure which gets the pointer of default_mod_on_rx_request to handle the incoming messages. this structure will pass to a initiator function and may call the "on_rx_response" function.

my structure definition:

struct pjsip_module mod_default_handler
{
...
pj_bool_t (*on_rx_response)(pjsip_rx_data *rdata);
...
};

I set the value of "on_rx_response" into this:

mod_default_handler.on_rx_response = &pjsuaMyClass::default_mod_on_rx_request;

but I got following error:

pjsuamyclass.cpp:24:35: error: assigning to 'pj_bool_t (*)(pjsip_rx_data *)' (aka 'int (*)(pjsip_rx_data *)') from incompatible type 'pj_bool_t (pjsuaMyClass::*)(pjsip_rx_data *)'

what should I do to pass this function as my handler?

Aucun commentaire:

Enregistrer un commentaire