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

  • 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.

主站蜘蛛池模板: 宁波市| 涡阳县| 全椒县| 西华县| 宜丰县| 乌兰浩特市| 拜泉县| 乌拉特中旗| 五大连池市| 马关县| 祁门县| 德令哈市| 来宾市| 桓台县| 乌海市| 日喀则市| 云霄县| 包头市| 霍邱县| 梁山县| 盐津县| 特克斯县| 曲靖市| 秦皇岛市| 搜索| 瑞安市| 鹰潭市| 开封县| 汕尾市| 济阳县| 茌平县| 武夷山市| 桃源县| 内江市| 贵阳市| 阿坝县| 泸州市| 临颍县| 获嘉县| 阳朔县| 灵璧县|