[comp.lang.c++] References

kanner@Apple.COM (Herbert Kanner) (07/26/89)

I wonder what the formal language rule is which forces the following
interpretation on

	int *&pl;

namely:  "pl is a reference to a pointer to an integer."  What disallows
the interpretation 

	int *(&pl); i.e. int pl;?

Finally, how about

	int &*pl;

Is pl here a pointer to a reference to an integer?
-- 
Herb Kanner
Apple Computer, Inc.
{idi,nsc}!apple!kanner
kanner@apple.com

dan@oresoft.uu.net (Daniel Elbaum) (07/27/89)

In article <3079@internal.Apple.COM> kanner@Apple.COM (Herbert Kanner) writes:
:I wonder what the formal language rule is which forces the following
:interpretation on
:
:	int *&pl;
:
:namely:  "pl is a reference to a pointer to an integer."  What disallows
:the interpretation 
:
:	int *(&pl); i.e. int pl;?

	int *&pl;

is illegal, since a reference delarator must generally be followed
by an initializer.  A reference is not a pointer but an alias;
given

	int *ip;
	int &pr = ip;

*pr === *ip and &pr === &ip.

Since a reference cannot exist in a vacuum, declaring
a name for the value of the antecedent of a vacuous
reference can have no meaning.


:Finally, how about
:
:	int &*pl;
:
:Is pl here a pointer to a reference to an integer?

It parses that way, but since there's no such thing as
a pointer to a reference, such a declaration can't be used.
-- 
The workaday world must remain transparent to those who maintain it if
they are to find inspired within them a vision of the history they create.

({uunet,tektronix,reed,sun!nosun,osu-cis,psu-cs}!oresoft!(dan)@oresoft.uu.net)