Closed itskemo closed 3 months ago
https://github.com/Mooophy/Cpp-Primer/blob/abcb44b77668abaca539c482d359d17f5a0e3d7f/ch02/README.md?plain=1#L415C1-L415C26
int i = -1, &r = 0; // illegal, r must refer to an object. const int i = -1, &r = 0; // legal.
How come &r = 0; is legal on the second line but the line above it is illegal?
&r = 0;
I believe this is incorrect because in C++, a reference must be initialized to refer to an already existing object, not a literal value like 0? 🙏
https://github.com/Mooophy/Cpp-Primer/blob/abcb44b77668abaca539c482d359d17f5a0e3d7f/ch02/README.md?plain=1#L415C1-L415C26
How come
&r = 0;
is legal on the second line but the line above it is illegal?I believe this is incorrect because in C++, a reference must be initialized to refer to an already existing object, not a literal value like 0? 🙏