By-Reference vs. By-Copy

Thursday, December 4th, 2008

For those of you who do not know what by-reference and by-copy refer to, the refer to the way an argument is passed between functions. When an argument is passed by copy, it creates a new copy of the variable in memory.  When an argument is passed by reference, only the pointer to the variable is copied to the next function.  The main reason for this is that with pass-by-reference, you can modify a variable in subsequent functions and the changes will be present in the calling function.  For more info on pointers, watch this video. (more…)