Another (somewhat) similar concept is a
reference type. A reference type is an alias to an existing object in memory. References must be initialized. We describe a reference type as
type_name followed by an ampersand
&.
Example:
int main()
{
int x = 123;
int& y = x;
}
Now we have two different names that refer to the same
int object in memory. If we assign a different value to either one of them, they both change as we have one object in memory, but we are using two different names:
int main()
{
int x = 123;
int& y = x;
x = 456;
// both x and y now hold the value of ...