I came across code today that looked like:
result = (this->*(*c))(¶m)
The main part that confuses me is the this->*(*c) What does it mean to have the asterisk operators between the arrow (->) and the name of the variable we're accessing (c).
What you have here is an operator which you don't see very often.
->* is a single operator. It is the pointer-based counterpart to .* and is a member access operator.
It is used if you have an object to use a member on (e.g. a function), but don't know the concrete member (it's stored in a variable).
Let's split it up:
this // object to work on
->* // member access operator
(*c) // dereference pointer pointing to member function (c is a pointer-to-pointer)
(¶m) // call member function stored in c on this passing ¶m to the function
See also: http://en.cppreference.com/w/cpp/language/operator_member_access
Edit: This post also contains a good explaination on what is happening here: https://stackoverflow.com/a/6586248/1314789
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With