The reference declarator can be used to declare references outside functions:
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.
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|