0

Please explain me Pass by value and pass by reference

What is use of these

23rd Dec 2021, 3:40 AM
Pradeep Pogunulla
Pradeep Pogunulla - avatar
2 Answers
+ 2
The terms “pass by value” and “pass by reference” are used to describe how variables are passed on. To make it short: pass by value means the actual value is passed on. Pass by reference means a number (called an address) is passed on which defines where the value is stored. https://blog.penjee.com/passing-by-value-vs-by-reference-java-graphical/ https://www.educative.io/edpresso/pass-by-value-vs-pass-by-reference https://pediaa.com/what-is-the-difference-between-pass-by-value-and-pass-by-reference/amp/ https://stackoverflow.com/questions/373419/whats-the-difference-between-passing-by-reference-vs-passing-by-value https://courses.washington.edu/css342/zander/css332/passby.html
23rd Dec 2021, 6:24 AM
NEZ
NEZ - avatar
+ 1
When you're passing by value the CPU copies the value and uses it somewhere else.. for example in a function. When you change this value in the specific function and the function ends, nothing will be changed. On the other hand if you pass the variable by a reference the CPU will get physical address of that variable and changing its value in function will change the variable even in the place where you were calling that function.
23rd Dec 2021, 7:21 AM
Krysto Foxik đŸ„
Krysto Foxik đŸ„ - avatar