@[渣儿](/space/show?uid=13117) 迭代器啊,参考代码:
```cpp
vector<int> vec;
for ( vector<int>::iterator it=vec.begin( ); it!=vec.end( ); ++it )
cout<<*it<<endl;
// it是一个迭代器
```
如果想要了解更多请自行搜索。
当然用C++11版foreach也行:
```cpp
vector<int> vec;
for ( auto it : vec )
cout<<vec<<endl;
// 这里it的类型就是数组元素的类型
```
注意以上两种方法**都只能依次访问vector内的全部元素**。
by Prurite @ 2018-08-30 16:01:37
@[渣儿](/space/show?uid=13117) 第二段代码写错了,应该是这样:
```cpp
vector<int> vec;
for ( auto it : vec )
cout<<it<<endl;
// 这里it的类型就是数组元素的类型
```
by Prurite @ 2018-08-30 16:02:24
不会啊不就是把i改成了一个 *it 嘛
by _FILARET_ @ 2018-08-30 16:04:04
@[星烁晶熠辉](/space/show?uid=54160) @[deadpool123](/space/show?uid=84121) 嗯嗯谢谢大佬们,蒟蒻不常使用迭代器呢,以后会注意的QωQ
by Ouaoan @ 2018-08-30 16:08:55
@[渣儿](/space/show?uid=13117) 在编译时输入-Wall 也会有警告。
by codesonic @ 2018-08-30 16:11:36
哦对了为什么我用`Golang`写个P1001都会显示警告啊:
[提交记录](https://www.luogu.org/record/show?rid=10180901)
有大佬能解答一下吗
by yjxyjx @ 2018-08-30 16:12:22
哦对了为什么我用`Golang`写个P1001都会显示警告啊:
[提交记录](https://www.luogu.org/record/show?rid=10180901)
有大佬能解答一下吗
by yjxyjx @ 2018-08-30 16:12:22
@[yjxyjx](/space/show?uid=51211) 翻译:
> 缓存使用失败:权限不足。
~~就是评测机不让你在上面创缓存文件,没什么影响~~
by Prurite @ 2018-08-30 16:23:42
~~才一条,我一般五条起步~~
by SSerxhs @ 2019-01-08 20:07:47