+ 1
I don't understand what is the passing by reference?
help me please đ
4 Answers
+ 3
Passing by reference is where you are not passing a copy of the value (such as "pass by value") but instead a reference to the value such as the memory address of the variable.
For example, if you had a variable called age that you set to 5 and passed it to a function by value the function would work on a copy of age. On the other hand, if you passed it by reference the function would change the age variable itself rather than changing a copy.
+ 2
sorry .... that was a typo.
+ 1
Akash Pal / @ Lewis well done.
@Lemina to put it in another way:
if u pass a variable to someone (like a method) to process over it ..... if you pass it "by value" it means that the method only can work on a copy of the "value" that is inside the "variable" but it never will be able to change the original value inside the variable.
and if you pass it "by reference" ... the method can change the value inside the variable......