Possible Duplicate:
Function References
I found this code in a book ,
typedef int (&foo)(int,int);
What does it mean ? Is this reference to a function ? If yes, Why is it used for ? And how is it different from pointer to a function like this .
typedef int (*foo)(int,int);
Is this just an enhancement in C++ which is not in C ?
EDIT :
#include <iostream>
#include <typeinfo>
using namespace std;
int f (int , int ) {return 0;}
int main() {
int (&foo)(int,int) = f;
int (*fp)(int,int) = f;
std::cout<<typeid(foo).name()<<std::endl<<typeid(fp).name();
return 0;
}
When I print type of foo
and fp
it gives something like this :
FiiiE
PFiiiE
What is E
in the last. and why foo
is F
while fp
is PF
?