Re: Terminology problem

From: Gary Labowitz (glabowitz_at_comcast.net)
Date: 06/07/04


Date: Mon, 7 Jun 2004 09:49:27 -0400


"David White" <no@email.provided> wrote in message
news:3PSwc.6346$%r.89566@nasal.pacific.net.au...
> "Gary Labowitz" <glabowitz@comcast.net> wrote in message
> news:OemdnappJLlvcV7dRVn-uw@comcast.com...
> > "Edo" <edwardoJE@aking.com> wrote in message
> > news:40c3e69b$1@dnews.tpgi.com.au...
> > > Hello
> > > Is ( int &rVal = val; ) a declaration of a reference of type int
to
> > > the value of val
> > > Or
> > > A declaration of a variable rVal or type reference to int to the
value
> > > of val
> >
> > int &rVal = val;
> > decalres a new name for the variable val. It is rVal.
> > You may now use rVal and val interchangeably.
> > rVal is called a reference to val. It exists as long as val exists; that
> is,
> > they share the same scope.
>
> They don't necessarily share the same scope. A reference can be born
after,
> and die before, the object to which it refers, or it can refer to an
object
> that no longer exists. Obviously, you can't allow the latter case to ever
> happen.

Yes, I spoke too quickly there, and misspoke. You are right. Generally,
however, the reference is declared in the scope of the referenced variable
or in a function declaration as a parameter. Same scope in the first case,
different scope in the second. Thanks.

-- 
Gary