+ 30
Can any boby tell me the difference between call by reference and call by value?
I am very much confused about it.
42 odpowiedzi
+ 57
Call by reference passes the actual variable's location in memory to the function. Therefore, the function acts upon the location in memory, changing the original variable. Pass by value passes a copy of the variable into the function. Thus, any changes made inside the function do not reflect upon the original variable.
+ 10
Call By Value
1.copies the argument's actual value
2. original value is not get modified
3.parameter pass as a variable
Call By Reference
1.copies the argument's address
2.original value is get modified.
3. parameter pass as a pointer
+ 7
ok 👍
+ 6
In-Call by value, we can send the vale of variable as a
parameter.
In-Call by reference , we can send the memory address of
variable as a parameter
+ 5
thankuu sir😊☺
+ 4
thanx @varun
+ 4
In 'call by value' values in the argument list are copied to formal parameters of subroutine and any changes made to to parameter base won't affect the arguments....but in case of 'call by reference' address of the argument is copied into the parameter.this means that changes made to the parameters affects the argument
+ 4
we don't have any bobies here sorry
+ 4
does call by reference and call by address perform same functions?? because address locations are passed in both the cases....
+ 3
thanku @moksh_makhija for ur help
+ 3
but what this line state:
cout<<x<<","<<y;
+ 3
what will be the statement in java ?
+ 3
can you please tell the examples in java
+ 3
I try a short answer, which focuses on pragmatism: cbv is more secure as you play around with a new memory block and new variables. Depending on what you do in your function, you finally assign the result to the main program memory. Cbr is faster when the variable you want to work with is too costy regarding memory management. As you are working directly on the main function memory block, this should be handled with care but is much faster.
+ 3
in the call by reference method the function just works using the value of the variables and doesn't modify anything on the memory address where the variable exist
But in call by value method operation is performed by the function on the passed memory address of the variables.... so any changes procured gets reflected on the actual value of the function....
+ 2
in simple words call by value is simple calling by the the values i.e passing the values and calling th function.
whereas in call by the reference instead of the values a reference variable is passed which holds the original values along with the function calling.
call by reference does not show the values or inputs, it shows the reference
whereas call by value shows the actual input or value to everyone.
+ 2
during call by values, any change in the formal parameter is not reflected back to actual parameter where as in call by reference method it is reflected back.. in call by reference the called function creates a new set of variables and copies the values of arguments
+ 2
call by value passes the value of the variable like functionname(a) bt in call by ref we passes the address of the variable for eg functionname(&a)
+ 2
Call by value means that our function is dealing with the values of passing variables only i.e, function is getting a copy of original values of variable while
call by reference means function is dealing with original variable i.e, making change in that variable will affect our original values also.
+ 2
Who are bobys?)