当前位置: 首页 > news >正文

网站制作 杭州企业网络搭建方案

网站制作 杭州,企业网络搭建方案,几大网络公司排名,将page转换为wordpressC笔记之从数组指针到函数数组指针(使用using name和std::function) 参考笔记: C之指针探究(三):指针数组和数组指针 C之指针探究(十三):函数指针数组 C之指针探究(二):一级指针和一维数组 C之指针探究(十一):函数名的…

C++笔记之从数组指针到函数数组指针(使用using name和std::function)

参考笔记:
C++之指针探究(三):指针数组和数组指针
C++之指针探究(十三):函数指针数组
C++之指针探究(二):一级指针和一维数组
C++之指针探究(十一):函数名的本质和函数指针
C++笔记之从使用函数指针和typedef到使用std::function和using
C++之指针探究(八):指针函数和函数指针

code review!

文章目录

  • C++笔记之从数组指针到函数数组指针(使用using name和std::function)
    • 1.指向数组的指针
    • 2.指向动态数组的指针
    • 3.函数指针数组和std::function、using结合使用的例程
      • 形式一:MathFunction mathFunctions[] = {add, subtract, multiply, divide};
      • 形式二:MathFunction *mathFunctions[] = {add, subtract, multiply, divide};
      • 形式三:MathFunction *mathFunctions = new MathFunction[4];
    • 附代码

1.指向数组的指针

在这里插入图片描述

2.指向动态数组的指针

在这里插入图片描述

3.函数指针数组和std::function、using结合使用的例程

形式一:MathFunction mathFunctions[] = {add, subtract, multiply, divide};

在这里插入图片描述

形式二:MathFunction *mathFunctions[] = {add, subtract, multiply, divide};

在这里插入图片描述

形式三:MathFunction *mathFunctions = new MathFunction[4];

在这里插入图片描述

附代码

形式一:

#include <iostream>
#include <functional>// 定义不同类型的函数
int add(int a, int b) {return a + b;
}int subtract(int a, int b) {return a - b;
}double multiply(double a, double b) {return a * b;
}double divide(double a, double b) {return a / b;
}// 创建函数指针数组类型
using MathFunction = std::function<double(double, double)>;int main() {// 创建函数指针数组MathFunction mathFunctions[] = {add, subtract, multiply, divide};// 使用函数指针数组调用不同函数double x = 10.0, y = 5.0;for (const MathFunction &func : mathFunctions) {std::cout << func(x, y) << std::endl;}return 0;
}

形式二:

#include <iostream>
#include <functional>// 定义不同类型的函数
int add(int a, int b) {return a + b;
}int subtract(int a, int b) {return a - b;
}double multiply(double a, double b) {return a * b;
}double divide(double a, double b) {return a / b;
}// 创建函数指针数组类型
using MathFunction = std::function<double(double, double)>;int main() {// 创建指针数组并初始化MathFunction *mathFunctions[] = {add, subtract, multiply, divide};// 使用指针数组调用不同函数double x = 10.0, y = 5.0;for (MathFunction *func : mathFunctions) {std::cout << (*func)(x, y) << std::endl;}return 0;
}

形式三:

#include <iostream>
#include <functional>// 定义不同类型的函数
int add(int a, int b) {return a + b;
}int subtract(int a, int b) {return a - b;
}double multiply(double a, double b) {return a * b;
}double divide(double a, double b) {return a / b;
}// 创建函数指针数组类型
using MathFunction = std::function<double(double, double)>;int main() {// 创建指针数组并初始化MathFunction *mathFunctions = new MathFunction[4];mathFunctions[0] = add;mathFunctions[1] = subtract;mathFunctions[2] = multiply;mathFunctions[3] = divide;// 使用指针数组调用不同函数double x = 10.0, y = 5.0;for (int i = 0; i < 4; ++i) {std::cout << mathFunctions[i](x, y) << std::endl;}// 释放内存delete[] mathFunctions;return 0;
}
http://www.ysxn.cn/news/2421.html

相关文章:

  • 网站建设教程pdf百度云俄国搜索引擎yandex入口
  • 网站点击率代码html网页制作用什么软件
  • 各行各业网站建设服务周到seo诊断a5
  • 梅林做网站万能搜索
  • 做网站的花费小红书推广平台
  • 阿里云做网站开发吗头条热点新闻
  • 大庆做网站公司长沙网络营销顾问
  • wordpress怎么加联系工具外贸网站优化
  • 在旅行社做网站运营北京网站推广服务
  • 网站建设需要哪些东西自媒体推广渠道有哪些
  • 手机在线做网站推销广告
  • 手机网站建设视频教程合肥seo招聘
  • 做我的狗哪个网站可以看有什么好的网站吗
  • b2c2b网站有哪些百度app关键词优化
  • 怎么注册网站的步骤网络营销公司哪家可靠
  • 网站上传模板后在线网页生成器
  • 做网站一个月可以赚多少企业培训课程表
  • 做网站 多页面网址怎么弄win7运行速度提高90%
  • java web 网站开发百度推广助手下载
  • 动易网站安装子目录中朋友圈广告推广平台
  • qq空间做单页网站网络产品运营与推广
  • 茶叶网络营销网站建设论文自媒体135的网站是多少
  • 长春移动端网站设计搜关键词网站
  • 网站制作 温州十堰seo
  • 教育类网站前置审批长沙seo研究中心
  • 网站制作里面链接怎么做湖南有实力seo优化
  • 百度上做网站需要钱吗关键词挖掘爱网站
  • 红色风格网站无人区在线观看高清1080
  • 创意网站推荐安卓优化清理大师
  • 自己做整个网站的流程搜索引擎的网站