+ 1
What is the difference between call by value and call by reference?
4 Réponses
+ 6
call by value
the values passed are copied in the function arguments. and the changes occur to the function arguments only. So no change is reflected in original variables.
call by reference
the address of the variables is passed to function.
so if any change is made to the function arguments the change will reflect in original values also.
so call by value is like working on photocopy of original document where no change is made to original document.
call by reference us like working on original document itself. so changes are reflected there.
+ 4
Call by value passes a copy of the value stored inside a variable to the function. Whatever happens, the variable itself won't be affected. However, pass by reference passes the memory in which the variable is stored to the function. In essence, it passes the variable itself. Changes to the variable inside the function affect the variable itself, as the memory in which the variable is stored is being accessed and modified.
+ 2
In call by Value method the value is passed as an argument to function. But in call by reference method the address of the variable is passed as an argument to function. Next in call by Value method any changes made in the formal parameters will not be reflected in actual parameters. In reference method any changes made in the formal parameters will be reflected in the actual parameters (calling function). Another difference is call by Value method works on the copy of the original data. But call by reference method it works on the original data.
0
thanks for anwsering