[Q]Object:formal definition and description?

  • Thread starter Steven T. Hatton
  • Start date
S

Steven T. Hatton

Steven said:
That's kind of what I expected.

I have an easier was to determine that a function isn't an object. It is
explicitly stated in 1.8 of the Standard.


I have yet to really examine references, but that was more or less what I
expected. Does this mean references aren't really runtime 'things'? IOW,
are they bound to something else at compile time? I believe what I'm
asking is whether references are always static.

I know my level of understanding of references is below that which I can
gain from carefully reading the FAQ, so I'll do my homework before
pursuing it further.

This is a somewhat telling passage from 3.5:

"A name is said to have linkage when it might denote the same object,
*reference*, function, type, template, namespace or value as a name
introduced by a declaration in another scope:..." (*emphasis* mine)

So we can probably assume the namable 'things' in the list other than
object
are not objects. Note that this includes references.

OTOH: "The storage duration categories apply to references as well. The
lifetime of a reference is its storage duration." - 3.7 of PL-C++03 (The
Standard)

And also TC++PL(SE) pg 98:
"[A] reference isn't an *object* that can be manipulated the way a pointer
is:

PP: [&ii]\
\
\
rr:---> ii:

In some cases, the compiler can optimize away a reference so that there is
no *object* representing that reference at run-time." (emphasis mine)

This is starting to sound more and more like wave particle duality. :-/
 
E

E. Robert Tisdale

Steven T. Hatton wrote:

[snip]

int i = 999;
int j = 0;
int* p = &j;

p is a *pointer* to j.
*p is a *reference* to j.

*p = 666; // means
j == 666; // is true

*p is another name for j.

p = &i; // a pointer can be *reseated*

Now, *p is a *reference* to i and

*p == 999; // is true

Pass by reference

void f(int&);

is typically implemented as

void f(int*);

meaning that
the compiler passes the [virtual] machine address of the object
to represent a reference or a pointer to an object.
 
S

Steven T. Hatton

Alf said:
Wrong question. The key point is that a C++ reference cannot be
re-seated; if a reference R refers now to object X, then R refers to
object X until R
ceases to exist. There are no operations on the reference itself, and in
many cases (but not all) it need not occupy any storage.

I have some things I want to add to this discussion, but first I want to
finish clause 3. I just found this in 3.9/9 "An /object type/ is a
(possibly cv-qualified) type that is not a function type, *not* a
*reference* type, and not a void type."

Now, if I can remain conscious for the next 4 pages, I'll be back with a few
observations regarding references. Probably in a followup to Robert's most
recent post in this thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top