5.array
1 #include <iostream> 2 #include <array> 3 #include <algorithm> 4 using namespace std; 5 6 //array是栈上的数组,自动回收,不能增删查改 7 8 9 //算法迭代函数 10 void change(int &x) 11 { 12 x += 1; 13 } 14 15 void main() 16 { 17 array<int, 10> my{ 1,2,3,4,5,6,7,8,9,0 }; 18 for (auto ib = my.begin(), ie = my.end(); ib != ie; ib++) 19 { 20 cout << typeid(ib).name() << endl; 21 cout << *ib << endl; 22 } 23 /*for (auto i : my) 24 { 25 cout << i << endl; 26 }*/ 27 28 //算法与容器的应用 29 for_each(my.begin(), my.end(), change); 30 for (auto i : my) 31 { 32 cout << i << endl; 33 } 34 cin.get(); 35 }