函数指针做函数参数,其中有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: 返回值,函数一定有返回 ...
随机推荐
- P2522 [HAOI2011]Problem b
还有三倍经验的吗(窒息) 思路 其实就是P3455套了个简单的容斥 把问题转化成f(n,m,k)-f(a-1,m,k)-f(n,b-1,k)+f(a-1,b-1,k)就可以了 和p3455几乎一样的代 ...
- Neo4j 文档
Graph Fundamentals 基础 Basic concepts to get you going. A graph database can store any kind of data u ...
- pgAdmin的数据恢复
DOC 本地添加server 1.设置备份.恢复的exe路径.一般在pgAdmin的安装路径下可以找到 2.恢复restore,备份backup
- Linux 下上手 STC89C52RC
第一次接触单片机,自然选择了简单的51单片机.然而我的操作系统是 Linux .在 Windows 下上手51似乎很容易.但是 Linux 上搭建 51 开发环境不是很顺. 那么谈谈 Linux 我如 ...
- Linux安装svn客户端
Red Hat Linux 1.安装$ yum install subversion 2.常见问题1.执行svn报错:cannot set LC_CTYPE localevi /etc/profile ...
- 1、Ansible简介及简单安装、使用
参考Ansible权威指南:https://ansible-tran.readthedocs.io/en/latest/index.html 以下内容学习自马哥教育 Ansible: 运维工作:系统安 ...
- Select2 添加默认值
折腾很久才解决问题 $.ajax({ url: '@Url.Action("GetSystemSzzdItem", "CangpinGushi")', type ...
- 四: 使用vue搭建网站前端页面
---恢复内容开始--- 在搭建路由项目的时候的基本步骤 一:创建项目 安装好vue 搭好环境 (步骤在上篇博客中) 进入项目目录 cd 目录路径/ 目录名 创建项目 ...
- 1.spring基础知识讲解
引言:以下记录一些自己在使用时pringle框架时的一些自己心得合成体会时,如有侵权,请联系本博主. 1. spring基本都使用 spring是一个开源的轻量级框架,其目的是用于简化企业级应用程序开 ...
- maven 引入外部jar包的几种方式
方式1:dependency 本地jar包 <dependency> <groupId>com.hope.cloud</groupId> <!--自定义--& ...