if the formal parameter should be able to change the value of the actual argumentthen you must use call-by-reference otherwisethe value of the actual argument cannot be changed by the formal parameter if the type is primitive typeuse call-by-value otherwisethe type is class type and is generally passed using call-by-constant-referenceunless it is an unusually small and easily copyable type ( type that stores two or fewer primitive typesput another way call-by-value is appropriate for small objects that should not be altered by the function call-by-constant-reference is appropriate for large objects that should not be altered by the function and are expensive to copy call-by-reference is appropriate for all objects that may be altered by the function because ++ adds rvalue referencethere is fourth way to pass parameterscall-byrvalue-reference the central concept is that since an rvalue stores temporary that is about to be destroyedan expression such as =rval (where rval is an rvaluecan be implemented by move instead of copyoften moving an object' state is much easier than copying itas it may involve just simple pointer change what we see here is that = can be copy if is an lvaluebut move if is an rvalue this gives primary use case of overloading function based on whether parameter is an lvalue or rvaluesuch asstring randomitemconst vector arr )string randomitemvector &arr )/returns random item in lvalue arr /returns random item in rvalue arr vector "hello""world}cout <randomitemv <endl/invokes lvalue method cout <randomitem"hello""world<endl/invokes rvalue method it is easy to test that with both functions writtenthe second overload is called on rvalueswhile the first overload is called on lvaluesas shown above the most common use of this idiom is in defining the behavior of and in writing constructorsand this discussion is deferred until section return passing in ++there are several different mechanisms for returning from function the most straightforward mechanism to use is return-by-valueas shown in these signaturesdouble averagedouble adouble )largetype randomitemconst vector arr )vector partialsumconst vector arr )/returns average of and /potentially inefficient /efficient in ++ these signatures all convey the basic idea that the function returns an object of an appropriate type that can be used by the callerin all cases the result of the function call is an rvalue howeverthe call to randomitem has potential inefficiencies the call to partialsum similarly has potential inefficienciesthough in ++ the call is likely to be very efficient