The .* and ->* operators enable you to call a member function without having to know the function’s name. Remember, however, that when using these operators, you have to parenthesize the expression as follows:
A a; // create objectvoid (A::*pmf)() = &A::f; // create pointer to member// the two pairs of parentheses are needed here:(a.*pmf)(); // call A::f() thorough pointer to member
Omitting the first pair of parentheses, as in the following example, is a common mistake:
a.*pmf(); // error, missing parentheses
Although some compilers might accept it, this is not the correct C++ syntax. Always use two pairs of parentheses when calling a member function through either .* or ->*.