- 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.
推薦閱讀
- AngularJS Testing Cookbook
- Practical Data Science Cookbook(Second Edition)
- Offer來了:Java面試核心知識點精講(原理篇)
- HBase從入門到實戰
- 精通網絡視頻核心開發技術
- Building Minecraft Server Modifications
- Web程序設計(第二版)
- Mastering Apache Spark 2.x(Second Edition)
- Go并發編程實戰
- Node.js全程實例
- MATLAB 2020從入門到精通
- 區塊鏈底層設計Java實戰
- C/C++程序員面試指南
- Python深度學習:模型、方法與實現
- C語言程序設計