//函数与函数对象
#include <iostream>
using namespace std;
//两种定义函数的方式
int answer = 42;
int max1(int arg1, int arg2) {
return arg1 >= arg2 ? arg1 : arg2;
}
//编译器在编译期会将auto替换为变量实际的类型
//auto& 可以对数组 a 中的元素进行修改.auto不行
//关于尽量少用using namepace std: https://blog.csdn.net/my_precious/article/details/49701339
//关于auto用法 https://www.cnblogs.com/KunLunSu/p/7861330.html
//关于引用的说明 https://www.cnblogs.com/stemon/p/4421178.html
auto max2(int arg1, int arg2) -> int {
return arg1 >= arg2 ? arg1 : arg2;
}
const auto& ask2() {
return answer; }
Functional Programming in C++ 学习笔记FPpr6
最新推荐文章于 2020-05-31 11:46:45 发布
本文记录了学习Functional Programming in C++的过程,探讨了如何在C++中应用函数式编程思想,包括高阶函数、不可变数据和递归等概念。
摘要由CSDN通过智能技术生成