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

  • Mastering C++ Programming
  • Jeganathan Swaminathan
  • 138字
  • 2021-07-02 18:28:49

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.

主站蜘蛛池模板: 长宁县| 共和县| 顺昌县| 开鲁县| 遂平县| 千阳县| 宁德市| 苍梧县| 嘉义县| 朝阳县| 蒙阴县| 关岭| 普陀区| 全州县| 来宾市| 仁怀市| 达孜县| 乐安县| 上犹县| 遂川县| 临安市| 封丘县| 马山县| 湖北省| 筠连县| 辉县市| 东海县| 平和县| 大宁县| 乳源| 宕昌县| 陇西县| 林口县| 刚察县| 诸城市| 华亭县| 太和县| 龙口市| 神木县| 鄄城县| 雅江县|