随笔分类 - C
c++ list erase函数
摘要:erase的作用是,使作为参数的迭代器失效,并返回指向该迭代器下一参数的迭代器。 删除的是list.begin()~--(--list.end())之间的元素 一个例子: #include <iostream> #include <list> using namespace std; list<in
c++ auto it 遍历改值的坑
摘要:for(auto it:arr) 利用这样遍历修改容器的值,是不可以成功修改的。 #include <iostream> #include <vector> using namespace std; vector<int> arr; void show1() { for (auto it : arr