Array <boost/array.hpp> boost::array<int,4> a = { 1, 2, 3 }; std::array is (as of C++11) part of the C++ standard use std::array instead of boost::array if you are using C++11 #include <iostream> #include <array> void cpp_11_array() { std::array<int, 4> a = {11, 22, 33, 44}; for (int i=0; i < a.size(); ++i) { std::cout << a.at(i); } for (std::array<int, 4>::const_iterator it = a.begin(); it != a.end(); ++it) { std::cout << *it; } } #include <iostream> #include <boost/array.hpp> int main() { boost::array<int, 4> a = {1, 2, 3, 4}; for (size_t i=0; i < a.size(); ++i) { std::cout << a.at(i); } for (boost::array<int, 4>::const_iterator it = a.begin(); it != a.end(); ++it) { std::cout *it; } return 0; } Previous 04. C++ Standard Template Library Next C++ Standardization FEATURED TAGS jekyll GitLab Ubuntu C++ Docker FRIENDS 黄玄的博客 乱序 前端外刊评论 天镶的博客 Luke 的自留地 Ebn's Blog SmdCn's Blog David's Game DHong Say 尹峰以为 解旻的博客