🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9271

Re: references - C++

#9271
From: Sam Kendall
Date: Mon, 08 Sep 1986 21:51
27 lines
1413 bytes
In article <6027@alice.uUCp> ark@alice.UucP (Andrew Koenig) writes:
>	1. A reference must always be initialized as it is delcared.

Except of course for formal arguments, which are initialized by their
actuals.

>	3. Therefore, the initializer for a reference must be an lvalue.

C++ Ref Man 3.6.3: 

    If the initializer for a reference to type T is not an lvalue an
    object of type T will be created and initialized with the
    initializer.  The reference then becomes a name for that object.

This is also the semantics of Fortran argument passing, and I'm sure
people calling Fortran from C++ are very happy -- `sin(2.3)', if `sin'
is a Fortran function, works!

>	char c;
>	char &cr = &c;		/* illegal -- &c is not an lvalue */

The last line is illegal because `&c' has the wrong type, not because
it is an rvalue.

---
Sam Kendall			sam@Think.COM
Thinking Machines Corp.		ihnp4!think!sam
Technical Details
Message-ID: <6170@think.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!sam
References: <6027@alice.uUCp>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!sam
From: sam@think.COM (Sam Kendall)
Newsgroups: net.lang.c
Subject: Re: references - C++
Message-ID: <6170@think.COM>
Date: Mon, 8-Sep-86 17:51:35 EDT
Article-I.D.: think.6170
Posted: Mon Sep  8 17:51:35 1986
Date-Received: Mon, 8-Sep-86 20:51:42 EDT
References: <6027@alice.uUCp>
Reply-To: sam@godot.think.com (Sam Kendall)
Organization: Thinking Machines, Cambridge, MA
Lines: 27