5 Hip hip array – C++ arrays
This chapter covers
- Exploring the concept of object collection
- Introduction to Arrays and their role in C++
- Working with single and multi-dimensional arrays
- Unraveling the std::array container
Up to this point in your C++ journey, you learned how to work only with single objects (variables) in your code. In this chapter, you will learn how to work with multiple objects, generally known as collections.
We start by explaining how different data structures are used to manage and manipulate collections of objects, and the general concept of collections. In this chapter, we also introduce the basic concept of C++ containers, which are designed to simplify the task of managing collections of objects by providing a set of methods and operators that allow you to insert, remove, search, and traverse the elements stored in them.
You will then learn about arrays, which are a fixed-size list of elements. We start with C-style arrays, which are still widely used in C++ - you will learn all about their role, and how and when to implement them in your code. You will also learn about multidimensional arrays, which are a more complex grid (matrix) of two arrays or more. You will practice an interesting program that emulates a spreadsheet, using a multidimensional array.