Created
July 8, 2014 17:53
-
-
Save tmplt/7e62566bb9898fb1706b to your computer and use it in GitHub Desktop.
legal and illegal references
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int i = 1024, i2 = 2048; // i and i2 are both ints | |
int &r = i, r2 = i2; // r is a reference bound to i; r2 is an int | |
int i3 = 1024, &ri = i3; // i3 is and int; ri i a reference bound to i3 | |
int &r3 = i3, &r4 = i2; // both r3 and r4 are references | |
int &refVal4 = 10; // error: initializer must be an object | |
double dval = 3.14; | |
int &refVal4 = dval; // error: initiazlier must be an int object | |
double dval2 = 4.5345; | |
double &refVakD = dval2; // a reference may be bound to an object of same type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment