我的代码如下:
#include <iostream>
using namespace std;
typedef void (fp)(const char*, int&);
typedef void(*fp1)(const char*, int&);
typedef void(&fp2)(const char*, int&);
void f(const char * a, int& b)
{
cout << a << " " << b;
}
int _tmain(int argc, _TCHAR* argv[])
{
fp * pf = f;
int i = 3;
pf("nihao", i);
fp1 pf1 = f;
pf1("nihao", i);
fp2 rf = f;
rf("nihao", i);
return 0;
}
主要是要适应这种诡异的写法;然后就是函数声明后,可以当做类型来使用;然后就是对于函数来说,指针和引用本质上是一样的。但是其他类型就不能这么认为和处理。