int num = 0;
int *ptrNum = #
int &refNum = num;

Which one is the correct representation of reference variable in the memory-table 1 or table 2?
If table 2,then why a pointer is an object and a reference isn't?
If both representations are incorrect then please provide a correct representation and an explanation for why a reference isn't an object.
Which one is the correct representation of reference variable in the memory-table 1 or table 2?
It could be either, or neither.
In this case, there is no need for storing the address of the object, so the table 1 would be enough. In another example, an address of the referenced variable could be needed. Such as when the reference is an argument of a non-inlined function.
please provide a correct representation
draft N4140 of the C++ standard [dcl.ref]/4:
It is unspecified whether or not a reference requires storage
How it could be stored is not specified at all.
an explanation for why a reference isn't an object.
The same document defines object as
[intro.object]/1
... An object is a region of storage ...
If a reference is not defined to have storage, then it's not defined to be an object.
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