C++ Tutorial: passing arguments by Value / ReferenceIn C++ arguments can be passed to a function by value or by reference. By ValueThis is the default way for passing arguments to a function. String S = "abc"; String S2; S2 = SomeFunction(S); By ReferenceWhen an argument is passed by reference, you are passing the address of the argument instead
of its value. The function can modify the original argument. TDateTime Date1 = Date; unsigned short Year, Month, Day; Date1->DecodeDate(&Year, &Month, &Day);Some types of variables are always passed by reference, without the need of an ampersand. This is the case for arrays, objects and structures. |
|