C++ 函数指针 函数名作为参数
来源:互联网 发布:云计算开发招聘 编辑:程序博客网 时间:2024/04/27 21:21
1.函数指针声明
typedef 返回类型(*函数指针类型名)(函参列表);
例子:
typedef int (*pf)(const int& a,const int& b);
2.函数指针例子
// MethodPoint.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>using namespace std;typedef int (*pf)(const int& a,const int& b);int sum(const int& a,const int& b){return a + b;}int minus(const int& a,const int& b){return a - b;}int doSometing(const int& a,const int& b, pf p){return p(a, b);}int _tmain(int argc, _TCHAR* argv[]){cout << doSometing(1, 2, &sum) << endl;cout << doSometing(1, 2, &minus) << endl;system("pause");return 0;}
http://www.waitingfy.com/?p=816
- C++ 函数指针 函数名作为参数
- C语言数组名作为函数参数
- C语言:数组名作为函数参数
- C语言中,数组名作为参数传递给函数时,退化为指针
- C语言中,数组名作为参数传递给函数时,退化为指针
- C语言中,数组名作为参数传递给函数时,退化为指针
- 数组名作为函数参数时会退化为指针
- 数组名作为函数参数时,退化为指针
- 数组名作为函数参数
- 数组名作为函数参数
- 数组名作为函数参数
- 数组名作为函数参数
- 数组名作为函数参数
- 函数名作为参数传递
- 数组名作为函数参数
- C/C++ 将函数名作为函数参数传递
- c_指针_一维数组名作为函数参数
- C---数组名作函数参数
- 将进程加入一个作业中所涉及的几个函数(C++)
- 软件工程总结
- Hbase API高级特性-比较过滤器
- kindle DXG 安装多看
- 用javascript实现求某个范围内最大素数
- C++ 函数指针 函数名作为参数
- xcode升级到5.0.2之后,cocos2d-x-2.2下的所有工程,第一次打开时编译报错的解决办法
- JAVA笔记【20131201】
- 网络编程常用API
- 再谈软件开发过程
- hdu 4681 String (dp预处理+枚举)
- 职业规划
- centos内核修改
- 【机器学习-斯坦福】学习笔记8 软间隔 核函数