Error with address of parenthesized member function

From the error message, it looks like you’re not allowed to take the address of a parenthesized expression. It’s suggesting that you rewrite

fPtr = &(myfoo::foo);  // main.cpp:14

to

fPtr = &myfoo::foo;

This is due to a portion of the spec (ยง5.3.1/3) that reads

A pointer to member is only formed when an explicit & is used and its operand is a qualified-id not enclosed in parentheses […]

(my emphasis). I’m not sure why this is a rule (and I didn’t actually know this until now), but this seems to be what the compiler is complaining about.

Hope this helps!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)