Keynslug Keynslug - 1 month ago 9
C++ Question

How is reference implemented internally?

Just wonder how is it implemented actually across different compilers and debug/release configurations. Does standard somehow provides recommendations on its implementation? Does it differ anywhere?

I tried to run a simple program where i have been returning non-const references and pointers to local variables from functions but it worked out the same way. So is it true that reference internally is just a pointer?

Answer

The natural implementation of a reference is indeed a pointer. However, do not depend on this in your code.