Lines 17–18 use a range-based for
statement to multiply each element of items
by 2. In line 17, the rangeVariableDeclaration indicates that itemRef
is an int
reference (&
). Recall that a reference is an alias for another variable in memory—in this case, one of the array
’s elements. We use an int
reference because items
contains int
values and we want to modify each element’s value—because itemRef
is declared as a reference, any change you make to itemRef
changes the corresponding element value in the array
.
18.216.220.21