What is the difference between pass by reference and pass by value?
Utilisateur anonyme
Pass-by-value -> at run-time a copy of the parameter is made in RAM, and changes are made to the copy instead of the original -> making a copy of all the data passed into a function, everytime the function is called is sub-optimal -> for example copying a vector is O(n) vs. passing-by-reference which is O(1) -> passing by value requires the programmer to return the copy made at run-time; otherwise it will loose scope Pass-by-refence -> at run-time a copy of the parameter is not made in RAM, and changes are made directly to the parameter -> does not require the programmer to return a value at the end of the function call