上一页 1 2 3 4 5 6 7 8 ··· 48 下一页
摘要: 使用内联函数就相当于是使用lamdba函数,对于函数的命令指令直接进行替换 #include<iostream> #include<cstdlib> using namespace std; #define f(x) x*x*x; //C语言内联, c++严格要求类型 inline int get( 阅读全文
posted @ 2021-07-21 00:55 python我的最爱 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1.断言(assert) #include<iostream> #include<cassert> using namespace std; //区别用指针的大小 int divv(int a, int b) { assert(b != 0); //断言 return a / b; } int ma 阅读全文
posted @ 2021-07-21 00:01 python我的最爱 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 1.使用bind构造适配器操作,这里可以使用默认的参数 #include<iostream> #include<functional> using namespace std; using namespace std::placeholders; int add(int a, int b, int 阅读全文
posted @ 2021-07-20 23:38 python我的最爱 阅读(68) 评论(0) 推荐(0) 编辑
摘要: 使用bind可以将函数从类成员变量中提取出来 这里以结构体的类成员函数作为说明 #include<iostream> #include<functional> using namespace std; using namespace std::placeholders; struct MyStruc 阅读全文
posted @ 2021-07-18 13:44 python我的最爱 阅读(391) 评论(0) 推荐(0) 编辑
摘要: 模板的嵌套指的是模板里面嵌套数据类型如vector和list等 // // Created by Administrator on 2021/7/17. // #include<iostream> #include<vector> #include<list> using namespace std 阅读全文
posted @ 2021-07-17 22:35 python我的最爱 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 1.使用function定义一个函数模板,然后将函数模板进行赋值 function<int(int, int)> fun1 = add; //包装函数 2.构造函数模板, 将函数进行做输入进行传递 template<class T, class F> T run(T t1, T t2, F f) { 阅读全文
posted @ 2021-07-17 20:14 python我的最爱 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 单链表是一种向前操作的数据结构 1.初始化 forward_list<int> list1{11, 2, 13, 4, 15} 2.排序 list1.sort() 3.翻转 list1.reverse(); 4.合并 list1.merge(list2) 5.初始化 list1.assign(10, 阅读全文
posted @ 2021-07-14 01:22 python我的最爱 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 使用initializer_list<int> 可以使用{}作为参数传入到函数中 #include<iostream> #include<initializer_list> using namespace std; void show(initializer_list<int> list) { fo 阅读全文
posted @ 2021-07-14 00:12 python我的最爱 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 1. 删除其他类型的输入函数,可以保证精准匹配输入 #include<iostream> using namespace std; //函数声明 = delete; void show(char num) = delete; //精确匹配, 删除额外的情况 void show(int num) = 阅读全文
posted @ 2021-07-13 23:37 python我的最爱 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 1.static_cast基本类型转换 int main1() { //printf("%d", 10.2); //printf("%f", (float)1); //printf不会完成数据类型转换 //printf("%d", static_cast<int>(10.2)); //默认转换 pr 阅读全文
posted @ 2021-07-13 23:13 python我的最爱 阅读(191) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 48 下一页