|
|
|
|
|
by stormbrew
1585 days ago
|
|
> A reference is a pointer that is never null. This isn't even theoretically true: void blah(int &x) { x++; }
int main() {
int *x = NULL;
blah(*x);
}
You can definitely write a smart pointer that more or less provides some kind of guarantee about this (with a combo of runtime checks and typefoo) but references only provide a guarantee that they are not statically initializable to null, which is very different. |
|