about pointer to funtion

Jun 16, 2008 at 5:58am
This is a question from Stroustrup's book(The C++ programming language special ed.)

Q: what does the following mean? what would it be good for?
typedef int (&vifii) (int, int);

THE END OF THE Q.

My guess: does this typedef define a type of pointer to function?
but usually it is in the following form:

typedef int (*vifii) (int, int);

Why in the question is there a & instead of *? What's the answer for Stroustup's question?

Thanks in advance.
Jun 16, 2008 at 6:27am
& means reference
1
2
3
4
5
6
7
8
9
int F1(int a, int b){ ... }; 
typedef int (&vifii) (int, int);

int main() 
{ 
int a = 1, b = 3; 
vifii x = F1; 
x(a, b); 
} 
Jun 16, 2008 at 7:56am
so, that means it defines a type of reference to a function? It seems I didnot know this conception from anywhere? As far as I know there is just pointer to function.
Anyway, can you reply the second part of the question? viz. what would it be good for?
Jun 16, 2008 at 8:09am
The same rules apply as the difference between a reference to a variable and a pointer to a variable.
Topic archived. No new replies allowed.