- 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.
推薦閱讀
- Python 3.7網(wǎng)絡(luò)爬蟲(chóng)快速入門(mén)
- 嵌入式軟件系統(tǒng)測(cè)試:基于形式化方法的自動(dòng)化測(cè)試解決方案
- Spring 5.0 By Example
- CockroachDB權(quán)威指南
- Java 開(kāi)發(fā)從入門(mén)到精通(第2版)
- 前端跨界開(kāi)發(fā)指南:JavaScript工具庫(kù)原理解析與實(shí)戰(zhàn)
- Kinect for Windows SDK Programming Guide
- Elasticsearch Server(Third Edition)
- Mastering Apache Maven 3
- Android開(kāi)發(fā)案例教程與項(xiàng)目實(shí)戰(zhàn)(在線(xiàn)實(shí)驗(yàn)+在線(xiàn)自測(cè))
- 軟件品質(zhì)之完美管理:實(shí)戰(zhàn)經(jīng)典
- Visual Basic程序設(shè)計(jì)上機(jī)實(shí)驗(yàn)教程
- HTML5+CSS3 Web前端開(kāi)發(fā)技術(shù)(第2版)
- C專(zhuān)家編程
- JSP程序設(shè)計(jì)實(shí)例教程(第2版)