A reference is an alias. It is similar to a pointer but with
some changes.
[...]
Good posting, but you missed the two most obvious differences
from the user's point of view (and thus, to take into
consideration when designing the interface):
-- A reference cannot be null; it must designate an actual
object. If you want an optional value, you'll have to use a
pointer.
-- A pointer cannot be initialized to point to a temporary. If
you want your client to be able to pass the results of an
arbitrary expression, then you must use a reference to
const.
Because of these considerations, from a user's point of view, a
reference to a const is actually more like pass by value than a
pointer, i.e. given:
void func1( std::string ) ;
void func2( std::string const& ) ;
void func3( std::string const* ) ;
, there is almost no difference between the first two for the
user; it is the third that is different.