TITLE: References, const pointers, and storage (more) [ Continued discusssion about the difference between references and const pointers. -adc ] PROBLEM: thp@PROBLEM_WITH_INEWS_DOMAIN_FILE (Tom Payne) What capability would an automatically dereferenced const pointer have that reference does not? Or vice versa? RESPONSE: kanze@lts.sel.alcatel.de (James Kanze), 17 Aug 95 In C++, pointers are objects: they have identity, manifested by a unique address. References are *not* objects, and do not have identity. References define a name equivalence; semantically, they are more closely related to the Fortran `equivalence' statement than they are to pointers. A simple example: struct A { int &a1 ; int &a2 ; } a ; struct B { int *b1 ; int *b2 ; } b ; What is guaranteed by the standard: first, sizeof( A ) >= 1 (since A is an object, although it contains no objects), whereas sizeof( B ) >= 2, since B contains two objects, each of which must have a positive size. Second: &b.b1 != &b.b2, since b1 and b2 are objects, and must have an identity manifested by a distinct address. There is no such guarantee concerning a1 and a2.