#include "stdafx.h" #include <string> using std::string; int _tmain(int argc, _TCHAR* argv[]) { bool *pf(const string &,const string &); //pf为指向函数的指针,它所指向的函数带有两个const string的形参,返回值为bool型 typedef bool (*cmpFcn)(const string &,const string &); //cmpfcn是一种指向函数的指针的名字。该指针类型为“指向返回bool型并带有两个const string 引用形参的函数的指针” bool lengthCompare(const string &,const string &); bool (*)(const string &,const string &); cmpFcn pf1=0; //定义pf1、并初始化为0 cmpFcn pf2=lengthCompare(); //pointer type mathces functions's type; 定义pf2、并初始化为lengthCompare(); pf1 =lengthCompare(); //赋值,把pf1赋值为legthCompare(); pf2 =pf1; //赋值,把pf1赋值给pf2 int (*ff(int))(int*,int); //ff is a function taking an int and returning a function pointer //the function pointed to returns an int and takes an int* and an int return 0; }