I was wondering why this question wasn't discussed in stack overflow? reference is just an other name to variable so how does execution happen at memory level
are references implemented as pointers inside?
How references are implemented is purely an implementation detail. But Yes, most implementations would implement them using pointers.sizeof
operator applied on an reference gives you the size of the element it referes to.
What is the size of the reference itself?
C+11 Standard: § 8.3.2.4
It is unspecified whether or not a reference requires storage (3.7).
Note that, Unspecified means that an compiler implementation does not need to document how it implements a reference. Neither should you consider the implementation to be anything specific. In short, the language standard treats reference implementation as an detail which user of the language does not need to know and hence it abstracts this detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With