TITLE: References, const pointers, and storage [ This follows a big argument about the difference between references and const pointers. -adc ] PROBLEM: ??? Essentially, a reference is an automatically dereferenced const pointer. With regard to objecthood, there is NO DIFFERENCE between references and const pointers. RESPONSE: thp@PROBLEM_WITH_INEWS_DOMAIN_FILE (Tom Payne) [...] That is not correct. [...] In C++ a reference is not an object. In particular, the draft standard says in the section on references (8.3.2), "It is unspecified whether or not a reference requires storage." The term "unspecified" means that it is up to the implementation, and the implementation doesn't have to tell you what it will do, and needn't even be consistent. RESPONSE: Steve Clamage (clamage@Eng.Sun.COM) But this is exactly what the ANSI C Standard (footnote 65) says of any const whose address is not used. Of course, there are circumstances where storage must be allocated anyway, whether for references or const pointers, and in such cases they are "objects" in this sense. RESPONSE: kanze@lts.sel.alcatel.de (James Kanze), 16 Aug 95 Why don't you read the quote from the C++ standard. There is *no* case where a reference must occupy storage. A simple example: struct A { int& ri ; int i ; A() ; } ; In this structure, it is perfectly possible that the offset of i == 0. Compare: struct B { int *const pi ; int i ; B() ; } ; A a ; B b ; // This assert is *not* guaranteed. assert( (void*)( &a.i ) != (void*)( &a ) ) ; // This one is. assert( (void*)( &b.i ) != (void*)( &b ) ) ; As both Pete Becker and Steve Clamage have pointed out, a pointer *is* an object, and must occupy storage. From an OO point of view, a pointer has identity, which in C++ is materialized by a unique address. A reference has no such identity, but simply introduce a name alias, and so requires no such unique address.