references - C++

Bjarne Stroustrup bs at alice.UucP
Sat Sep 6 11:36:18 AEST 1986


Karl W. Z. Heuer writes:

> BMS-AT!stuart writes:
> >[re the declaration of reference types "foo(char &c)"]
> >I don't like this.  It violates the nice consistent way that C expressions
> >work.  'char *c' means that '*c' is of type char.  '&c' is not of type
> >char in any other context.
>
> I am also somewhat uneasy about calling it "char &c".  The consistent way to
> declare it would be "char *&c", since you have to write "&c" to get ahold of
> the "char *" object you are really using.

The notation T& is the C++ notation for a reference to an object of type T.
	char& c;	declares c to be a reference to a char
	char*& r;	declares r to be a reference to a char*
& is a declarator operator exactly like *



More information about the Comp.lang.c mailing list