随笔分类 -  《C++ Primer》

摘要:10.3.2 Lambda Expression(匿名函数) #include <iostream> #include <algorithm> #include <vector> #include <string> #include <numeric> using namespace std; bo 阅读全文
posted @ 2018-11-05 00:51 Hk_Mayfly 阅读(158) 评论(0) 推荐(0)
摘要:#include <iostream> #include <algorithm> #include <vector> #include <string> #include <numeric> using namespace std; int main() { vector<int> vec = { 阅读全文
posted @ 2018-11-01 22:07 Hk_Mayfly 阅读(194) 评论(0) 推荐(0)
摘要:1. auto result = find(vec.cbegin(), vec.cend(), val); find返回一个指向与第一个元素的相同值的变量,如果find没有找到,它将会返回第二个参数,来指向失败。 2.int n = count(vec.cbegin(), vec.cend(), v 阅读全文
posted @ 2018-10-31 22:16 Hk_Mayfly 阅读(176) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-10-24 15:54 Hk_Mayfly 阅读(1) 评论(0) 推荐(0)
摘要:9.5.1其他方法去构造string 1.我们能够通过 substr 选择开始位置和数量 #include <bits/stdc++.h> using namespace std; int main() { string str1 = "helloworld!"; string str2 = str 阅读全文
posted @ 2018-10-24 15:51 Hk_Mayfly 阅读(216) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; int main() { vector<int> vec; cout << "vec size: " << vec.size() << " capacity: " << vec.capacity() << e 阅读全文
posted @ 2018-10-23 22:44 Hk_Mayfly 阅读(186) 评论(0) 推荐(0)
摘要:forward_list有特殊版本的insert和emplace, push_back和emplace_back对forward_list无效,push_front和emplace_front对vector和string无效。 #include <bits/stdc++.h> using names 阅读全文
posted @ 2018-10-23 22:24 Hk_Mayfly 阅读(200) 评论(0) 推荐(0)
摘要:9.2.1迭代器 1.迭代算术操作只适用于string, vector, deque和array,其他的容器类型都不行。 2.在容器中的元素从begin(first)开始到end(last)结束(不包括end)。 3. list<string>::iterator it5 = a.begin(); 阅读全文
posted @ 2018-10-23 21:39 Hk_Mayfly 阅读(203) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-10-22 22:17 Hk_Mayfly 阅读(1) 评论(0) 推荐(0)
摘要:文章转自:https://www.cnblogs.com/kingcat/archive/2012/05/09/2491847.html 自己在学习中,对此原文的基础之上进行补充。 什么是缓冲区 缓冲区又称为缓存,它是内存空间的一部分。也就是说,在内存空间中预留了一定的存储空间,这些存储空间用来缓冲 阅读全文
posted @ 2018-10-13 13:41 Hk_Mayfly 阅读(1847) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-10-10 22:04 Hk_Mayfly
该文被密码保护。
posted @ 2018-10-10 21:56 Hk_Mayfly
该文被密码保护。
posted @ 2018-10-10 21:43 Hk_Mayfly
该文被密码保护。
posted @ 2018-10-10 21:33 Hk_Mayfly
该文被密码保护。
posted @ 2018-10-10 21:17 Hk_Mayfly
该文被密码保护。
posted @ 2018-10-10 21:11 Hk_Mayfly 阅读(1) 评论(0) 推荐(0)
摘要:top-level const:变量或者引用自身不能被改变 int *const p = &a;//指针p不能被改变(p中储存的地址) const int val = 42;//变量val不能被改变 low-level const:变量引用或者指向地址不能改变 const int *p = &a;/ 阅读全文
posted @ 2018-09-22 20:24 Hk_Mayfly 阅读(164) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-09-22 20:14 Hk_Mayfly 阅读(1) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-09-22 20:12 Hk_Mayfly 阅读(2) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-09-22 20:08 Hk_Mayfly 阅读(0) 评论(0) 推荐(0)