函数指针与回调函数
2016-02-12 17:53
302 查看
#include<iostream> using namespace std; void show(int a) { cout << a <<"...."; } int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } void func_test(int(*p)(int, int), int a, int b) //回调函数 { cout<<p(a, b)<<endl; } int main() { show(3); void(*p)(int); //函数指针 p = show; //show函数名是地址 p(4); func_test(add,4,5); func_test(sub, 4, 5); cout<<"hello"<<endl; system("pause"); return 0; }
相关文章推荐
- android、Java下判断两个String是否相等 、EditText输入是否为空,
- 线程同步 - 互斥量
- bash脚本之一(变量+数组)
- [C++]标准库容器
- vector
- pthread_cleanup_push与pthread_cleanup_pop的目的 作用
- 【翻译自mos文章】OGG的集成捕捉模式支持Oracle database标准版么?
- Android ImageButton的使用。
- 开源库FlycoRoundView解析
- windows创建添加系统变量
- 真是瞎了我的狗眼啊
- [C++]容器和算法
- Scala 具体的并行集合库【翻译】
- Android:30分钟弄明白Touch事件分发机制
- PHP基本语法
- zoj1234 chopsticks 经典dp
- iOS 【UIKit-转换坐标系(2)】
- HDOJ 1087 Super Jumping! Jumping! Jumping! (dp)
- 侧滑菜单的页面 动态填充给 新闻页面
- Windows 8.1 更改CapsLock按键为Esc