What is the advantage of passing arguments by reference? When and why is passing an object by reference preferable?
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In passing arguments by reference method, the called function does not create its own copy of original values; rather, it refers to the original values only by different names i.e., the references. Thus the called function works with the original data and any change in the values gets reflected to the data. The passing an object by reference method is preferable in situations where we want the called function to work with the original object so that there is no need to create and destroy the copy of it.