Re: Reference to void
Greg Herlihy wrote:
> Such uniformity is misleading - because it creates the false
> impression that name of a reference is analogous to the name of
> pointer. When the reality is the names are used in opposite ways:
>
> For example:
>
> int * const p;
>
> "p" names the const pointer object and not the object that it may be
> pointing to (and which is not named in this declaration). With
> reference declarations, the situation is just the opposite:
>
> int& ref = i;
>
> "ref" names the object being referenced ("a reference may be thought
> of as the name of an object") and the there is no, other referencing
> object. So ref is not a "reference to an int" as much as ref is "the
> int being refererced" in this expression.
Following your logic, and given:
struct B {};
struct D : B {};
void f()
{
D d;
B& r = d;
}
r were to be called "a reference to D", or, better still, a "D
reference". Consequently, given only
void g(B& b);
the parameter of g() would be of type "B or something derived from B, I
cannot tell for sure, reference".
--
Gerhard Menzl
Non-spammers may respond to my email address, which is composed of my
full name, separated by a dot, followed by at, followed by "fwz",
followed by a dot, followed by "aero".
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]