Skip to main content

Corrupted reference

Posted in

One of the things that differs a reference from a pointer is the fact that any reference MUST be initialized (just like constants). One might think that this guarantees safe usage of references. But it doesn't. You should always be careful and stay on alert.

Consider this code

A *p = 0;
A &ref = *p;

We've got a corrupted reference which is totally unusable.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
f_ien_ship: