- 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.
推薦閱讀
- Facebook Application Development with Graph API Cookbook
- 精通軟件性能測試與LoadRunner實戰(第2版)
- Mastering Scientific Computing with R
- ASP.NET 3.5程序設計與項目實踐
- Python數據結構與算法(視頻教學版)
- Android程序設計基礎
- Swift 4從零到精通iOS開發
- 零基礎學C語言第2版
- Learning Material Design
- QPanda量子計算編程
- Tableau Desktop可視化高級應用
- C語言程序設計
- Python預測分析與機器學習
- Offer來了:Java面試核心知識點精講(框架篇)
- 虛擬現實:引領未來的人機交互革命