function pointers in c++ : error: must use '.*' or '->*' to call pointer-to-member function in function -


code snippet follows. not able understand why getting error.

void sipobj::check_each_field() { map <std::string, sip_field_getter>::iterator msg; string str; char name[20]; bool res = false; sscanf(get_payload(), "%s %*s", name); loginfo(lc()) <<  "invite:" << name; str = name; msg = sip_field_map.find(str); if (msg != sip_field_map.end()) {     sip_field_getter sip_field = msg->second;     res = (this).*sip_field(); } }   typedef bool (sipobj::*sip_field_getter)();  static map <std::string, sip_field_getter> sip_field_map;  sip_field_getter place holder function names 

(this).*sip_field(); 

there 2 problems expression:

  1. this pointer, must use ->* call member function via pointer on it.

  2. the function call (()) has higher precedence member-by-pointer operators (either .* or ->*), need parentheses correctly group expression.

the correct expression is:

(this->*sip_field)(); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -