views:

99

answers:

1

If the following from the C++ FAQ Lite is true: "a function name decays to a pointer to the function" (as an array name decays to a pointer to its first element); why do we have to include the ampersand?

typedef  int (Fred::*FredMemFn)(char x, float y);
FredMemFn p = &Fred::f;

And not just:

typedef  int (Fred::*FredMemFn)(char x, float y);
FredMemFn p = Fred::f;

In the second case Fred::f is a function and can decay to a pointer to that function.

I hope this question is not that stupid.

+7  A: 
Armen Tsirunyan
"There is function type in C++, but not member-function type." -> What exactly do you mean by that? Surely `FredMemFn` has a type?
FredOverflow
Armen Tsirunyan
FredOverflow
Armen Tsirunyan
FredOverflow
I'm astonished that this answer only got 1 (my) upvote so far... it's a great answer!
FredOverflow
@Armen Tsirunyan : thanks for this great answer !
Cedric H.