+ 2

What's the difference between call by value and call by reference with easy understanding eg.

I am stuck

25th Nov 2018, 2:29 PM
N Sin
N Sin - avatar
2 Antworten
+ 2
Call by value: the parameter of a function is a copy the actual value of the variable, not the variable itself. Any change to the parameter inside the function is lost when back from the function. Call by reference; the parameter is the location of the variable in memory. If you change the variable value, the new value is still visible when back from the function.
25th Nov 2018, 3:19 PM
ifl
ifl - avatar
+ 1
If you call by value, you create a copy of original variable, but if you call by reference you take the original variable and if you make some changes it will be applied to original variable because you already took the original variable.
25th Nov 2018, 2:35 PM
Mustafa K.
Mustafa K. - avatar