#include <iostream> #include <array> using namespace std; int main() { array<string, 5> strs { "one", "two", "three", "four", "five" }; // サイズ取得にsize()とか使える。 for (int i = 0; i < strs.size(); i++) { cout << strs[i] << endl; // 配列と同様に添え字でアクセス可能。 } cout << "-----" << endl; // Iterator対応してるのでこういうforの回し方もできる。 // (range based for は別途説明) for (array<string, 5>::iterator it = strs.begin(); it != strs.end(); it++) { cout << *it << endl; } return 0; }