STL vector的使用(三)遍历

来源:互联网 发布:apache ab get参数 编辑:程序博客网 时间:2024/06/01 08:08

一. vector的遍历总类:

1. 未用名字空间,使用vector 进行遍历:

for(std::vector<std::string>::size_type index = 0; index < vect.size();index++){std::cout << vect[index]   << std::endl;}

2. 使用名字空间,使用vector进行遍历:

for(int index = 0; index < vect.size();index++){cout << vect[index]   << endl;}

3.  利用迭代器,对vector进行遍历:

vector<string>::iterator it = vect.begin();for(;it != vect.end();it++){cout << *it  << endl;}




1 0