函数指针做函数参数,其中有typedef的相关,感觉这是构成大河的小溪
#include<stdio.h>
#include<stdlib.h>
#include<string.h> int Funcadd(int a, int b)
{
return a + b;
}
int Funcplus(int a, int b)
{
return a - b;
}
int Funcmul(int a, int b)
{
return a * b;
}
int Funcdiv(int a, int b)
{
return a / b;
} typedef int(*MyTypeFunc)(int a, int b);
int mainop(MyTypeFunc mypointer)
{
int temp = mypointer(5,6);
return temp; } int mainop2(int(*MyPointFunc)(int a, int b))
{
int temp=MyPointFunc(4, 3);
return temp;
} int main()
{
int temp1=mainop(Funcadd);
printf("%d\n",temp1); temp1 = mainop2(Funcadd);
printf("%d\n", temp1); temp1 = mainop2(Funcplus);
printf("%d\n", temp1); temp1 = mainop2(Funcmul);
printf("%d\n", temp1); temp1 = mainop2(Funcdiv);
printf("%d\n", temp1); system("pause");
}
函数指针做函数参数,其中有typedef的相关,感觉这是构成大河的小溪的更多相关文章
- Day8 函数指针做函数参数
课堂笔记 课程回顾 多态 virtual关键字 纯虚函数 virtual func() = 0; 提前布局vptr指针 面向接口编程 延迟绑定 多态的析构函数的虚函数. ...
- go语言基础之数组指针做函数参数
1.数组指针做函数参数 示例: package main //必须有个main包 import "fmt" //p指向实现数组a,它是指向数组,它是数组指针 //*p代表指针所指向 ...
- go语言基础之指针做函数参数用地址传递
1.指针做函数参数 示例: package main //必须有个main包 import "fmt" func swap(p1, p2 *int) { *p1, *p2 = *p ...
- go语言基础之指针做函数参数
1.指针做函数参数 示例: package main //必须有个main包 import "fmt" func swap(a, b int) { a, b = b, a fmt. ...
- typedef void(*Fun) (void)是什么意思 函数指针(回调函数) 和函数对象总结
https://blog.csdn.net/FreeApe/article/details/49124043 bool (*pf)(const string &,const string &a ...
- Delphi 函数指针(函数可以当参数)
首先学习: 指向非对象(一般的)函数/过程的函数指针 Pascal 中的过程类型与C语言中的函数指针相似,为了统一说法,以下称函数指针.函数指针的声明只需要参数列表:如果是函数,再加个返回值.例如声明 ...
- C++中的函数指针和函数对象总结
篇一.函数指针函数指针:是指向函数的指针变量,在C编译时,每一个函数都有一个入口地址,那么这个指向这个函数的函数指针便指向这个地址.函数指针的用途是很大的,主要有两个作用:用作调用函数和做函数的参数. ...
- [C/C++]如何解读返回函数指针的函数声明
今天在看<深入理解C++11>的时候,看到一段有意思的代码: int (*(*pf())())() { return nullptr; } 我立刻就懵了——从来没有见过这样的函数声明.那么 ...
- C/C++回调方式系列之一 函数指针和函数回调模式
一.函数指针 1. 函数的定义 return_type function_name(parameter list) { function_body } return_type: 返回值,函数一定有返回 ...
随机推荐
- 完全卸载oraclean安装
完全卸载oracle11g步骤:1. 开始->设置->控制面板->管理工具->服务 停止所有Oracle服务.2. 开始->程序->Oracle - OraHome ...
- (zhuan) Using convolutional neural nets to detect facial keypoints tutorial
Using convolutional neural nets to detect facial keypoints tutorial this blog from: http://danieln ...
- NRF24L01模块配置
发射数据时: (1)首先将nRF24L01配置为发射模式 (2)接着把接收节点地址TX_ADDR和有效数据TX_PLD按照时序由SPI口写入nRF24L01缓存区,TX_PLD必须在CSN为低 ...
- Installation Guide of Ubuntu 14.04, 64bit on Dell Server
Installation Guide of Ubuntu 14.04, 64bit on Dell Server 准备:U盘(已通过ultraiso刻录ISO镜像). 1.插入U盘: 2.启动服务器, ...
- 【译】第4节---简单的Code First示例
原文地址:http://www.entityframeworktutorial.net/code-first/simple-code-first-example.aspx 假设我们要为XYZ学校创建一 ...
- HDU 4301 Divide Chocolate(DP)
http://acm.hdu.edu.cn/showproblem.php?pid=4301 题意: 有一块n*2大小的巧克力,现在某人要将这巧克力分成k个部分,每个部分大小随意,问有多少种分法. 思 ...
- JqGrid 列时间格式化
{name:'createTime',index:'createTime',label:"创建时间", editable:false,formatter:"date&qu ...
- 1:Javascript的数据类型和相互转换
第一节:JavaScript的数据类型 他是弱类型 var 但是正是由于其实弱类 所以其后台的数据类型转换也是我们值得思考的 JavaScript的数据类型有两种 一种是原始类型 另外一种是对象类型 ...
- Scrapy创建爬虫项目
1.打开cmd命令行工具,输入scrapy startproject 项目名称 2.使用pycharm打开项目,查看项目目录 3.创建爬虫,打开CMD,cd命令进入到爬虫项目文件夹,输入scrapy ...
- 再谈java编码
一篇好文:从原理上搞懂编码——究竟什么是编码?什么是解码?什么是字节流? encode,即把字符按照指定的<编码gbk utf-8等>编码成该<编码>所表示的字节 decode ...