InterviewSolution
Saved Bookmarks
| 1. |
What is the advantage of passing arguments by reference? When and why is passing an object by reference preferable? |
|
Answer» In passing arguments by reference method, the called function does not create its own copy of original values; rather, it refers to the original values only by different names i.e., the references. Thus the called function works with the original data and any change in the values gets reflected to the data. The passing an object by reference method is preferable in situations where we want the called function to work with the original object so that there is no need to create and destroy the copy of it. |
|