Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
call by reference in c++ for example : void sqr(int &x){ x *= x; } you called this function by write sqr(x); what the difference..with call by reference the value of x is change..how it change?..first we should notice that in call by value the function creates a local variable which is the parameter and the modifying occur on the local variable so the variable which we passed as an argument not change..but with call by reference we don't create a local variable in fact the parameter is an another name of the variable which we passed..because in fact we pass the address not a value so in call by reference we save memory also.. sorry for my poor English .
10th Jul 2018, 8:21 PM
kais hasan
kais hasan - avatar