Chapter 15

Arrays

In This Chapter

arrow Expanding simple variables into an array

arrow Comparing the array to a rental car lot

arrow Indexing into an array

arrow Initializing an array

The variables declared so far have been of different types with different sizes and capabilities. Even so, each variable has been capable of holding only a single value at a time. If I wanted to hold three numbers, I had to declare three different variables. The problem is that there are times when I want to hold a set of numbers that are somehow closely related. Storing them in variables with names that bear some similarity of spelling such as nArg1, nArg2, and so on may create associations in my mind but not for poor, ignorant C++.

There is another class of variable known as the array that can hold a series of values. Arrays are the subject of this chapter and the next chapter. (Here I present arrays in general. In the next chapter, I look at the particular case of the character array.)

What Is an Array?

tip.eps If you are mathematically ...

Get Beginning Programming with C++ For Dummies, 2nd Edition 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.