Talk:Language Comparison Table: Difference between revisions

According to the C++ standard, references are clearly not objects
(T != T&)
(According to the C++ standard, references are clearly not objects)
Line 42:
 
:: The issue that some operations (like operator&) might not be pre-defined on the type T& is irrelevant. It does not have operator* as well. But assignment is defined on a LHS reference, as the code sample shows. This is why B = A; is perfectly legal when B is of int& and A is of int. When a reference like B is declared, this is a declaration of an object B. [[C++]] is a typed language, thus B need to have a type. This type is obviously not T, it is T&. --[[User:Dmitry-kazakov|Dmitry-kazakov]] 13:55, 5 August 2008 (UTC)
 
::: From the C++ standard (well, actually the last public draft of the 1998 standard), 8.3.2 References [dcl.ref]:
:::: 1 In a declarationT D where D has the form
::::: & D1
:::: and the type of the identifier in the declarationT D1 is “''deriveddeclaratortypelist'' T,” then the type of the
identifier of D is “''deriveddeclaratortypelist'' reference to T.” ''[...]'' [Note: a reference can be
thought of as a name of an object. ]
::: And later:
:::: 3 It is unspecified whether or not a reference requires storage (3.7).
::: Given that objects do require storage, this clearly shows that references are not objects.
::: Also note that the standard always mentions references explicitly after objects, where both objects and references can be used.
::: But of course you are invited to quote relevant parts of the standard (of a draft of your choice) to try to disproof me. --[[User:Ce|Ce]] 14:46, 5 August 2008 (UTC)
973

edits