function pointers in c++ : error: must use '.*' or '->*' to call pointer-to-member function in function
c++, function-pointers
Solution
(this).*sip_field();
There are two problems with this expression:
`this` is a pointer, so you must use `->*` to call a member function via pointer on it.
the function call (`()`) has higher precedence than the member-by-pointer operators (either `.*` or `->*`), so you need parentheses to correctly group the expression.
The correct expression is:
(this->*sip_field)();
Problem
Code snippet is as follows. Not able to understand why I am getting this 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` is a place holder for function names