1

I have a question, what is the purpose of passing reference with reference arguments when you can do it by passing by reference with pointers?

White Philosophy
  • 173
  • 2
  • 11

1 Answers1

2

References provide stronger guarantee and thus compiler can do better job for example at optimization.

Moreover accessing references provides more intuitive code than pointers (My opinion, some people argue opposite). With references you get rid of null-pointer dereference issue (atleast in sane programs).

So always try to use references and use pointers when no other option is present.

Mohit Jain
  • 30,259
  • 8
  • 73
  • 100