7.1 Introduction
This chapter introduces the topic of data structures—collections of related data items. We discuss array
s, which are fixed-size collections consisting of data items of the same type, and vector
s, which are collections (also of data items of the same type) that can grow and shrink dynamically at execution time. Both array
and vector
are C++ standard library class templates. To use them, you must include the <array>
and <vector>
headers, respectively.
After discussing how array
s are declared, created and initialized, we present examples that demonstrate several common array
manipulations. We show how to search array
s to find particular elements and sort array
s to put their data in order.
We build two versions of an instructor ...
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.