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

浙公网安备 33010602011771号