RAD Studio |  |

Simple References
See Also
Collapse All

The reference declarator can be used to declare references outside functions:

Copy Code

    int  i  = 0;
    int &ir = i;   // ir is an alias for i
    ir = 2;        // same effect as i = 2

This creates the lvalue ir as an alias for i, provided the initializer is the same type as the reference. Any operations on ir have precisely the same effect as operations on i. For example, ir = 2 assigns 2 to i, and &ir returns the address of i.

See Also

Referencing

Reference Arguments

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!