7.11 Wrap-Up

This chapter began our introduction to data structures, exploring the use of C++ Standard Library class templates array and vector to store data in and retrieve data from lists and tables of values. The chapter examples demonstrated how to declare an array, initialize an array and refer to individual elements of an array. We passed arrays to functions by reference and used the const qualifier to prevent the called function from modifying the array’s elements, thus enforcing the principle of least privilege. You learned how to use C++11’s range-based for statement to manipulate all the elements of an array. We also showed how to use C++ Standard Library functions sort and binary_search to sort and search an array, respectively. You ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.