在c++中序列for循环可以遍历数组、容器、string;
#include <iostream>
#include <vector>
using namespace std;
int main()
{
for (const auto str : {"aaa", "bbb", "ccc"})
{
cout << str;
}
cout << endl;
for (const auto v : { 1,2,3,4,5 })
{
cout << v;
}
cout << endl;
vector<string> v1;
v1.push_back("hahhaha");
v1.push_back("eeee");
for (auto& i: v1)
{
cout << i;
}
return 0;
}