Computer Applications
Answer
The principal reason for passing arguments by value is that the actual parameters that are used to call the method cannot be modified by the called method because any changes that occurs inside the method is on the method's copy of the argument value. The original copy of the arguments remains intact.
Related Questions
Identify the errors in the function skeletors given below :
float doer (int, float = 3.14) { }Given the method below, write a main() method that includes everything necessary to call given method.
int thrice (int x) { return x * 3 ; }When an argument is passed by reference,
- a variable is created in the function to hold the argument's value.
- the function cannot access the argument's value.
- a temporary variable is created in the calling program to hold the argument's value.
- the function accesses the argument's original value in the calling program.
What is the principal reason for passing arguments by reference ? In a function call, what all data items can be passed by reference ?