day1 C++为什么语法特性多 C++支持四种编程范式 面向过程 面向对象 泛型编程 函数式编程(lambda函数)
#include<iostream> using std::cout; using std::endl; //范式一:面向过程 int add1(int a, int b){ return a+b; } //范式二:面向对象 class Add{ public: int operator()(int a, int b); }; int Add::operator()(int a, int b){ return a+b; } //范式三:泛型编程 template<typename T> T add3(T a, T b){ return a+b; } //范式四:函数式编程 auto add4 = [](int a, int b) -> int { return a+b; }; int main(){ Add add2; cout<<add1(3,4)<<endl; cout<<add2(3,4)<<endl; cout<<add3(3,4)<<endl; cout<<add4(3,4)<<endl; return 0; }编译阶段进行语法检查
day2 C源代码 经预处理之后得到待编译代码 经编译之后得到目标文件 经链接后得到可执行文件
预处理命令之宏定义(简单的替换)
#define S(a,b) a*b m = S(3,4); //m = 3*4 S(int, p) = &n <=>int*p = &n3.实现COLOR系列封装 4.__attribute
day4 7个版本的快排 version1 version2单边递归法 version3无监督优化(以插入排序对比,找到监督项) version4基准值选择(优化时间复杂度的角度,使其稳定在O(nlogn)) 分为随机选取和三点取中法 version6混合算法(小数据使用无监督优化的插入算法)