Goldman Sachs Interview Question
AnalystsMr. Shekhar, Reference is not by address. BTW address is nothing but pass by value. For pass by Reference compiler shares reference of the variable. It is NOT address.
Sorry but Shekhar got the right answer.
Not sure why your complaining with invalid fact.
By value will send a copy of the original value/object thus the value/object isn't modified outside of the scope of the function.
By reference will send a reference of the value/object to the function and every modification made in the function are reflected to the variable/object outside of the function.
You pass value by reference when you pass the address to the function, even though the compiler // language does it for it, that how it done.
If you give an array, by default they pass those by reference for performance issue, your language / compiler does have default setting to pass some object type by reference or values.
though everything passed by reference, it send the address at which the variable/object is located outside the scope of the function, as to by value it doesn't pass an address but rather the raw value or duplicate the object and send the address of the new object copy...
Go learn more assembler, the compiler share by reference the address, your not making in sense in that reply.
Making a variable name in a function an alias for a variable in the calling program. This method of passing arguments is called passing by reference. Passing by reference allows a called function to access variables in the calling function. C++’s addition of the feature is a break from C, which only passes by value. Passing by value, recall, results in the called function working with copies of values from the calling program.
Two types of argument passing in a function:
- shekhar2010us February 10, 2011Call by reference pass the address of the variable, thus it changes the actual value of the variable, even outside the function.
Call by value passes the copy of the variable, thus it doesn't change the actual value of the variable.