Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

May a reference be more efficient than a pointer?

I'm wondering whether sometimes (depends on the platform or compiler or context in code etc) a reference can be more efficient than a pointer?

like image 931
Guillaume Paris Avatar asked May 29 '11 10:05

Guillaume Paris


1 Answers

May a reference be more efficient than a pointer?

Nopes! Not necessarily. The Standard doesn't say that either.

Most compilers implement reference mechanism via use of pointers. References were added to C++ to support operator overloading and not for efficiency.

like image 191
Prasoon Saurav Avatar answered Sep 29 '22 02:09

Prasoon Saurav