but of coursea range for loop would be more elegant unfortunatelythe natural code does not workbecause assumes copy of each value in the vector forauto arr ++ /broken what we really want is for to be another name for each value in the vectorwhich is easy to do if is referenceforauto arr /works ++xlvalue references use # avoiding copy suppose we have function findmax that returns the largest value in vector or other large collection then given vector arrif we invoke findmaxwe would naturally write auto findmaxarr )howevernotice that if the vector stores large objectsthen the result is that will be copy of the largest value in arr if we need copy for some reasonthat is finehoweverin many instanceswe only need the value and will not make any changes to in such caseit would be more efficient to declare that is another name for the largest value in arrand hence we would declare to be reference (auto will deduce constnessif auto is not usedthen typically non-modifiable reference is explicitly stated with const)auto findmaxarr )normallythis means that findmax would also specify return type that indicates reference variable (section this code illustrates two important concepts reference variables are often used to avoid copying objects across function-call boundaries (either in the function call or the function return syntax is needed in function declarations and returns to enable the passing and returning using references instead of copies parameter passing many languagesc and java includedpass all parameters using call-by-valuethe actual argument is copied into the formal parameter howeverparameters in +could be large complex objects for which copying is inefficient additionallysometimes it is desirable to be able to alter the value being passed in as result of thisc+has historically had three different ways to pass parametersand ++ has added fourth we will begin by describing the three parameter-passing mechanisms in classic +and then explain the new parameter-passing mechanism that has been recently added