Question d’entretien chez NVIDIA

Difference between call by value and call by reference

Réponse à la question d'entretien

Utilisateur anonyme

24 sept. 2018

In call by value, a copy of actual arguments is passed to respective formal arguments. While, in call by reference, the address of actual arguments is passed to formal arguments, hence any change made to formal arguments will also reflect in actual arguments. If data is passed by value, the data is copied from the variable used in for example main() to a variable used by the function. So if the data passed (that is stored in the function variable) is modified inside the function, the value is only changed in the variable used inside the function.