Difference between Call by value Vs Call by reference
Call by Value | Call by Reference |
In this case, a copy of actual data is created and passed to the function. | In this case, address of actual data is passed to the function. |
In this case, any changes in data modified by the function will not be reflected to actual data. | Since, address of actual data is available with the function, hence any change in data will be reflected to actual data also. |
Since in this case, copy of actual data is created, hence for large size of data its inefficient as it will need more memory and extra CPU cycles to copy all data. | Since, in this case, only address of actual data is passed, hence it’s not dependent of data size as pointer size will always be equal to size of an integer. |
For more information related to Call by value and Call by reference Click here.