On 16-09-2012 13:33, Jacob Carlborg wrote:
On 2012-09-15 23:30, Walter Bright wrote:

Doing null references in C++ is simple:

int *p = NULL;
int& r = *p;

r = 3; // crash

Won't that crash at the first assignment of "r", since you dereferencing
a null pointer?.


Nope, since in this context you're assigning it to an int&. So it really just means "r = p" if you assume that references are just pointers (which they are in most implementations).

D works like this too, if you pass a *p to a ref parameter and such.

--
Alex Rønne Petersen
a...@lycus.org
http://lycus.org

Reply via email to