- 博客(7)
- 收藏
- 关注
原创 C++中的auto的使用
遍历需要改变迭代对象 for(auto &i:s)string s = "hello";for (auto &i : s ) i = toupper(i); //改变成大写,影响s的值cout<<s<<endl; //s的值是 HELLO不需要改变迭代对
2018-08-28 17:55:03 838
原创 C++11新特性
先列在这里,慢慢填坑如果你的代码工作正常并且表现良好,你可能会想知道为什么还要使用C++ 11。当然了,使用用最新的技术感觉很好,但是事实上它是否值得呢? 在我看来,答案毫无疑问是肯定的。我在下面给出了9个理由,它们分为两类:性能优势和开发效率。获得性能优势理由1:move语义(move semantics)。简单的说,它是优化复制的一种方式。有时候复制很显然是浪费的。如果你从一个临时...
2018-08-28 17:42:56 414
原创 STL中的vector
注意assign的奇怪用法不同类型间的赋值 vector<int> A(3, 3); list<int> B(5, 4); A.assign(B.begin(), B.end()); // A = B会报错 cout<<A.size()<<"|"<<B.size()<<endl
2018-08-28 11:37:52 142
原创 STL 中堆heap
例子less&lt;int&gt;() 指下一层比上一层下大堆#include &lt;iostream&gt;#include &lt;vector&gt;#include &lt;algorithm&gt;using namespace std; int main() { int ia[9] = {0, 1, 2, 3, 4, 8, 9, 3, 5
2018-08-11 11:23:56 158
原创 STL 中双端队列deque
经典使用class Solution {public: vector<int> maxInWindows(const vector<int>& num, unsigned int size) { deque<int> state; vector<int> result; ...
2018-08-09 23:07:59 173
原创 c++中unsigned int的类型转换的坑 1-3 > 0 == true
unsigned int a = 3; int b = 1; int c = 4; cout<<"b-a = "<<b-a<<endl; cout<<"(unsigned int)(-2) = "<<(unsigned int)(-2)<<endl; co
2018-08-09 23:01:42 587
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人