Possible duplicate:
Error with round member function address
In this recent question, OP ran into a weird situation in C ++, which makes it illegal to accept the address of a member function if that member name is parentheses. For example, this code is illegal:
struct X { void foo(); }; int main() { void (X::* ptr)(); ptr = &(X::foo);
I looked through this and found that it is due to § 5.3.1 / 3 of the C ++ ISO specification, which reads
A pointer to a member is formed only when explicit and used, and its operand is an identifier not enclosed in parentheses [...]
Does anyone have any idea why the specification has this rule? This is specific to member pointers, so I would suspect that there is some grammatical ambiguity that solves this, but I honestly have no idea what it could be.
c ++ language-lawyer pointer-to-member
templatetypedef Aug 20 '11 at 19:51 2011-08-20 19:51
source share