+ 3

why call by reference and call by address is preferred by call by value??.

2nd Feb 2017, 1:28 PM
priyanka thakur
priyanka thakur - avatar
2 Réponses
+ 1
If I am understanding you question correctly the reason is because passing by value copies the data, and when you are passing objects it uses way more resources(memory, time to process, etc) to copy every object, especially for large or numerous items. for small programs it probably doesn't matter that much. also passing variables by reference into a function allows for you to "return" multiple values(1 for each value passed in if necessary) because it actually changes the variable in the function. If you are passing by value you can only return 1 variable.
2nd Feb 2017, 1:48 PM
Bill
Bill - avatar
+ 1
Thank u so much
2nd Feb 2017, 1:58 PM
priyanka thakur
priyanka thakur - avatar