您的位置:首页 > 其它

指向函数的指针_简单运用

2013-03-20 10:57 281 查看
#include <iostream>
#include <string>
#include <cctype>
#include <assert.h>
using namespace std;
#define  NDEBG

typedef bool (*cmpFcn)(const string &, const string &);
bool lengthCompare(const string &a, const string &b)
{
return a.size()>b.size()?1:0;
}

int main()
{
cmpFcn pf	=	lengthCompare;
cout<<"lengthCompare(hi,bye)		"<<lengthCompare("hias","bye")<<endl;
cout<<"pf(hi,bye)				"<<pf("hias","bye")<<endl;
cout<<"(*pf)(hi,hi)				"<<(*pf)("hi","hi")<<endl;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: