From -7379136659535175612
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,9d57bb38940f08c2
X-Google-Attributes: gidf78e5,public
From: stanley@West.sun.com (Stanley Friesen [Contractor])
Subject: Re: References to functions allowed?
Date: 1999/01/21
Message-ID: <787pg7$47r@abyss.West.Sun.COM>#1/1
X-Deja-AN: 435331760
X-Nntp-Posting-Host: ba2.west.sun.com
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <36A222B3.E51DFD28@ibm.net> <782ehu$7a5$1@engnews2.Eng.Sun.COM> <slrn7ac706.9h7.sbnaran@localhost.localdomain> <785g5t$644$1@engnews2.Eng.Sun.COM>
Organization: SunSoft South, Los Angeles, CA
X-UID: 0000000001
X-Status: $$$T
Newsgroups: comp.std.c++
Originator: clamage@taumet


In article <785g5t$644$1@engnews2.Eng.Sun.COM>,
Steve Clamage <clamage@Eng.Sun.COM> wrote:
>The syntax &rg is valid, but it does not give you the address
>of the reference. It gives you the address of what rg refers to.
>
>By contrast, if you write &pg, you get the address of variable pg.
>You cannot do that with references; C++ does not have the concept
>of the address of a reference.

For the very good reason that nothing in the standard actually requires
a reference occupy storage at all.

For instance the following use is perfectly conforming and reasonable:

extern LibClass libs_very_long_name_for_variable;

void func()
{
    LibClass &small = libs_very_long_name_for_variable;
    
    small->dosomething();
}


In the above the compiler can simply enter "small" into the symbol table as
an alias for the longer name.  Such a reference need never show up at all
in the compiled binary.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




