4 ms·
> C++ references surely are safer than pointer that can point to whatever they feel like and aren't initialized to any safe value. From the C programmer's pers
by cygx 5y ago
> C++ references surely are safer than pointer that can point to whatever they feel like and aren't initialized to any safe value.
From the C programmer's perspective, a reference is a constant pointer with automatic indirection.
As far as 'safety' is concerned, there's not much difference between
int& ref = ...;
and
int *const ptr = ...;
except in the most trivial of cases.
edit: However, this of course does not mean that references are useless within the C++ context - they do have an effect on how you write your code...