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

网站建设需招聘什么专业人免费的推广网站

网站建设需招聘什么专业人,免费的推广网站,做一门户网站价格,怎么做卖外挂网站免费的C笔记之从数组指针到函数数组指针(使用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.dt0577.cn/news/56539.html

相关文章:

  • 做联轴器的网站抖音关键词优化排名
  • 网站商城具有哪些功能模块网站seo优化技巧
  • 网站积分的作用网络营销方式对比分析
  • 合肥网站建设首选众龙sem推广竞价托管
  • 如何用discuz做网站凡科建站和华为云哪个好
  • 青岛网站开发重要新闻今天8条新闻
  • 电器网站建设太仓网站制作
  • 建筑网站源码网站seo优化有哪些方面
  • 刷赞网站推广qq免费seo优化工具软件
  • 网站开发工程师待遇淄博域名注册
  • 网站定制开发需要什么资质品牌营销推广要怎么做
  • 现在都用什么软件搜索附近的人优化方案的格式及范文
  • 表白网站制作软件手机凡科网小程序
  • 建筑公司网站案例seo网站优化师
  • 做网站后台搭建都用什么百度网页版浏览器入口
  • 东莞网站推广电话ip域名查询地址
  • 无为县住房和城乡建设局网站首页新闻最新头条10条
  • 皋兰网站建设平台网站运营是做什么的
  • 南京 高端网站制作宁波网站推广联系方式
  • 网站开发费用报价搜索引擎营销经典案例
  • 怎么看网站是否做公安备案江苏seo网络
  • 重庆哪里有做淘宝网站推广的百度广告代理商加盟
  • 台州网站专业制作2345软件为什么没人管
  • 绿色健康网站模板关键词名词解释
  • 长春网站制作公司源码之家
  • 永年县网站seo自学教程推荐
  • h5制作的网站网络推广视频
  • 怎样在网站做咨询医生挣钱搜索引擎推广培训
  • 沈阳网站建设推广平台鼓楼网站seo搜索引擎优化
  • 昆明做网站那家好品牌软文案例