answersLogoWhite

0


Best Answer

In Pass by value, the value changed in the variables in called function are not reflected in the same variables in calling function whereas in call by reference, it is reflected. Call by reference uses aliases to the variables.Reference means alias. int a=10; int m=&a means m is an alias of a when u change a, m also changes The same is used in call by reference call by value ex) int sum(c,d)would be called by sum(a,b) call by reference int sum(&c,&d)would be called by sum(a,b).

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

When using ByRef(), you are telling the computer to make a change to a specified memory location. for example if you have Var1 and you use a function with ByRef(Var1), any changes done in the function to Var1 are going to change the Var1 outside on the function. On the other hand, Using the ByVal() creates a second memory location. that is to say when you use ByVal(Var1), Var1 is not changed at the end of the function because the Var1 inside the function is a Completely different variable than the Var1 outside the functions even though they have the same name.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the advantages and disadvantages to passing arguments by reference?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the main advantage of passing arguments by reference?

the value can be pointed directly to the particular address which is specified


What is a difference between passing by value and passing arguments by reference in visual basic 6 procedures?

When we pass arguments my value, we are passing the value represented in the variable mentioned in the call, and not the variable itself. Therefore, any modifications made to that value will NOT be reflected in the variable mentioned in the call. Pass by reference, as the name suggests passes the reference of the variable mentioned in the procedure call. Any modifications made to the data of that variable is changed at the memory location of that data itself, and will be reflected in the variable itself, after the procedures completes.


What are the advantages and disadvantages of African traditional education?

The advantages of African traditional education include passing on of essential values from the community as well as defining the roles of both boys and girls distinctly. As for the disadvantages, the education was limited to the African culture and this is quite limiting in some ways for the students.


How can you change values in call by reference?

We don't call by reference, we call functions. The arguments passed to the function are passed (not called) either by value or by reference, depending upon the function signature (the prototype). When you pass by reference you are passing the actual variable, not a copy of the variable, thus the function can modify that variable's value directly. The only exception is when the parameter is declared a constant reference. Passing a pointer is essentially the same as passing by reference, however the pointer itself is passed by value. To pass a pointer by reference you must pass a pointer-to-pointer instead. Passing by value always copies the value, whether it is declared constant or not. But if it is declared constant, the function might as well accept a constant reference. Passing objects (instances of a class) by constant value will incur a performance penalty in making an unnecessary copy. If it is constant, there is little point in copying the object.


Why do you sometimes need to pass arguments to functions by reference?

You should always pass by reference unless there is good reason not to. Passing by reference always passes the object itself whereas passing by value always copies the object. Copying complex objects can severely impact upon performance which is why programmers try very hard to never pass anything larger than the CPU can cope with (typically 4 bytes on a 32-bit system and 8 bytes on a 64-bit system). Since a reference is effectively the address of an object and has the same length as a pointer, you can pass by reference either by passing a pointer or by passing an actual reference, depending on the function signature. The difference is that when you pass a pointer, the pointer is actually passed by value and is therefore copied. Also, pointers must also be dereferenced which incurs an extra layer of indirection that you do not incur when passing by reference. When you pass by reference you pass the object itself.


Show some points on advantage and disadvantage of teenager on internet?

Advantages: Homework, Research, Connecting With Friends, Playing Games, and Passing the time Disadvantages: Porn, Cyber bullying,& illegal downloads.


What argument passes in a method that will reference the content and can change the variable in the method?

That is called passing an argument by reference.


What do you call an argument that only has a copy of the arguments value and will not be affected by the method?

That is called passing an argument by value.


What are the advantages or disadvantages of riding motorcycle at the motorcycle lane?

One disadvantage is that cars and trucks use the motorcycle lane for passing other cars. A theoretical advantage would be that you would not need to compete with cages in a designated motorcycle lane.


What is an allusion in grammar?

An allusion is a passing reference or indirect mention of something.


When there are more waves passing through the reference point in a period of time which characteristic also increases?

when there are more waves passing through the reference point in a period of time, which wave characteristic also increase


When there are more waves passing through the reference point in a period of time which wave characteristic also increases?

when there are more waves passing through the reference point in a period of time, which wave characteristic also increase