+ 2
What's the difference between call by value and call by reference with easy understanding eg.
I am stuck
2 odpowiedzi
+ 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.
+ 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.