

InterviewSolution
Saved Bookmarks
1. |
What is diffrence between call by value and call by referance |
Answer» <th>BASIS FOR COMPARISON</th> <th>CALL_BY_VALUE</th> <th>CALL BY REFERENCE</th> \t\t\tBasicA copy of the variable is passed.A variable itself is passed.EffectChange in a copy of variable doesn\'t modify the original value of variable out side the function.Change in the variable affect the value of variable outside the function also.Calling Parametersfunction_name(variable_name1, variable_name2, . . . .);function_name(&variable_name1, &variable_name2, . . . .); //in case of object object.func_name( object);Receiving Parameterstype function_name(type variable_name1, type variable_name2, . . . .) { . . }type function_name( type *variable_name1, type *variable_name2, . . . .){ . . } //in case of object type function_name(class_type object_name) { . . }Default callingprimitive type are passed using "call by value".objects are implicitly passed using "call by reference".\t | |