Passing Built-In Arrays to Functions

The value of a built-in array’s name is implicitly convertible to the address of the built-in array’s first element. So arrayName is implicitly convertible to &arrayName[0]. For this reason, you don’t need to take the address (&) of a built-in array to pass it to a function—you simply pass the built-in array’s name. As you saw in Section 8.4, a function that receives a pointer to a variable in the caller can modify that variable in the caller. For built-in arrays, this means that the called function can modify all the elements of a built-in array in the caller—unless the function precedes the corresponding built-in array parameter with const to indicate that the elements should not be modified.

Software ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.