一. 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;
}