官术网_书友最值得收藏!

Code walkthrough

The following line declares an array of a fixed size (5) and initializes the array with five elements:

array<int,5> a = { 1, 5, 2, 4, 3 };

The size mentioned can't be changed once declared, just like a C/C++ built-in array. The array::size() method returns the size of the array, irrespective of how many integers are initialized in the initializer list. The auto pos = a.begin() method declares an iterator of array<int,5> and assigns the starting position of the array. The array::end() method points to one position after the last element in the array. The iterator behaves like or mimics a C++ pointer, and dereferencing the iterator returns the value pointed by the iterator. The iterator position can be moved forward and backwards with ++pos and --pos, respectively.

主站蜘蛛池模板: 莲花县| 衡东县| 巴林右旗| 琼结县| 神木县| 集安市| 常德市| 太白县| 竹北市| 平安县| 广元市| 岳西县| 双江| 报价| 冷水江市| 罗田县| 鄂托克旗| 遂宁市| 平谷区| 封开县| 民丰县| 钟祥市| 铜梁县| 根河市| 邵阳市| 辰溪县| 长宁县| 丰都县| 大荔县| 措美县| 松滋市| 西城区| 平果县| 鸡西市| 蓝山县| 安吉县| 班玛县| 平顺县| 奈曼旗| 平乐县| 定南县|