資源簡介
c++的指針特性學習之函數指針,代碼中給出了函數指針的聲明方式和使用方式,供大家使用函數指針參考
代碼片段和文件信息
//?設計模式.cpp:?定義控制臺應用程序的入口點。
//
#include?“stdafx.h“
#include?
#include?
using?namespace?std;
bool?lengthCompare(const?string?&a?const?string?&b)?{
return?a.size()?}
bool?(*pf)(const?string?&?const?string?&);?//聲明函數指針
typedef?bool?func(const?string?&?const?string?&);?//定義函數指針類型
typedef?bool(*funcP)?(const?string?&?const?string?&);
void?big(const?string?&a?const?string?&b
bool(*pf)(const?string?&?const?string?&))?{
//same?as?bool?pf(const?string?&const?string?&)
cout?<}
- 上一篇:c++11 bind庫使用
- 下一篇:設計模式之委托模式的demo
評論
共有 條評論