S
SasQ
Hello.
I wonder if literal constants are objects, or they're only
"naked" values not contained in any object?
I have read that literal constants may not to be allocated
by the compiler. If the Standard is saying that "object is
a region of storage", I deduce from that that literal constants
aren't objects because they may not be alocated as regions of
storage in the memory.
The Standard itself doesn't tell anything if literal constants
are objects or not [at least I haven't found anything]. It
only says that literal constants are expressions.
Are my thoughts correct?
I'm asking about this because some person told me that literal
constants are objects and that the following code prooves it:
const int& x = 7;
std::cout << x;
He said that it's an object because it is possible to set a
constant reference to it. Who's right here?
I wonder if literal constants are objects, or they're only
"naked" values not contained in any object?
I have read that literal constants may not to be allocated
by the compiler. If the Standard is saying that "object is
a region of storage", I deduce from that that literal constants
aren't objects because they may not be alocated as regions of
storage in the memory.
The Standard itself doesn't tell anything if literal constants
are objects or not [at least I haven't found anything]. It
only says that literal constants are expressions.
Are my thoughts correct?
I'm asking about this because some person told me that literal
constants are objects and that the following code prooves it:
const int& x = 7;
std::cout << x;
He said that it's an object because it is possible to set a
constant reference to it. Who's right here?