August 2012
Intermediate to advanced
976 pages
30h 17m
English
As with the library vector and string types, we can use a range for or the subscript operator to access elements of an array. As usual, the indices start at 0. For an array of ten elements, the indices are 0 through 9, not 1 through 10.
When we use a variable to subscript an array, we normally should define that variable to have type size_t
. size_t is a machine-specific unsigned type that is guaranteed to be large enough to hold the size of any object in memory. The size_t type is defined in the cstddef header, which is the C++ version of the stddef.h header from the C library.
With the exception that arrays are fixed size, we use arrays in ways that are similar to how we use vectors. For example, we ...
Read now
Unlock full access