函数指针的使用实例
来源:互联网 发布:.sit域名 备案 编辑:程序博客网 时间:2024/06/06 01:03
#include<iostream>using namespace std;int inc(int a){return (++a); } int multi(int *a,int *b,int *c) { return (*c=*a**b); } typedef int (*FUNC1)(int in);//typedef简化函数指针的定义 typedef int (*FUNC2) (int*,int*,int*); void show(FUNC2 fun,int arg1,int *arg2) { FUNC1 p = &inc;//使用函数名对函数指针进行赋值或初始化 //int temp = p(arg1);//使用函数指针 ,方式一 int temp = (*p)(arg1);//方式二//int temp = inc(arg1); //方式三 ,直接调用函数 fun(&temp,&arg1,arg2); printf("%d\n",*arg2); } int main() { int a; show(multi,10,&a); return 0; }
阅读全文
0 0
- 函数指针的使用实例
- c++ 函数指针使用实例
- C++类成员函数指针的使用实例
- 使用函数指针或静态模板的实例
- SSD6 Exercise0: 函数指针数组的使用实例
- Linux C 指针数组 数组指针 函数指针 的使用实例
- 一个函数指针的实例
- 函数指针的使用
- 函数指针的使用
- 函数指针的使用
- 函数指针的使用
- 指针函数的使用
- 函数指针的使用
- 函数指针的使用
- 函数指针的使用
- 函数指针的使用
- 函数指针的使用
- 函数指针的使用
- 使用Models 并 解决循环应用问题
- CSAPP LAB1 DataLab
- 爬虫笔记(10/1)--------http.cookiejar模块
- [Maven项目生命周期]
- python3 将中文句子中汉字数字转阿拉伯数字
- 函数指针的使用实例
- 什么是IO、内存?和他们的访问方式
- 骗子网站--正规网赚系统--www.j9m2.com--诈骗网站
- 数据库的select底层实现
- 排序算法
- String类的实现(深拷贝or浅拷贝)
- CTF线下攻防赛总结
- NoSQL资料汇集
- 进程IPC---共享内存