I’ve never used it before and just stumbled upon it in an article… I thought it would be the equivalent to *x->y but apparently it isn’t.
Here’s what I tried, and gave me an error:
struct cake {
int * yogurt;
} * pie;
int main(void) {
pie = new cake;
pie->yogurt = new int;
return pie->*yogurt = 4;
}
Its used when you have pointers to member functions.
When you have a pointer to a function of a class, you call it in much the same way you would call any member function
object.membername( … )
or
objectptr->membername( … )
but when you have a member function pointer, an extra * is needed after the . or -> in order that the compiler understand that what comes next is a variable, not the actual name of the function to call.
Here’s an example of how its used.