🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c++
Article #106

some small questions

#106
From: Bjarne Stroustrup
Date: Wed, 19 Mar 1986 15:42
43 lines
2289 bytes
> From: gjditchfield@watrose.UUCP (Glen Ditchfield)
> Subject: some small questions
> Organization: U of Waterloo, Ontario
> 
> Can some kind soul tell me how "real" C++ handles these problems? We use a
> buggy pre-release here, so I can't just try them.

Get a proper release then (I hate seing my old bugs after I have managed to
make the fixes made available).

> - Does C++ make some distinction between ++x and x++, where x is of a user-
>   defined class?

No.

> If operator++() is written to return the incremented value,
>   C++ could handle x++ by saving x, calling ++, and passing on the saved value.

Too subtle.
The compiler cannot even assume that an overloaded ++ is an increment operation.

> - Does "void fred( gorf& const g)" make syntactic sense? What I am trying to
>   say is that fred uses a reference to the actual parameter, _but_can_not_
>   _alter_it_. This is like the CONST parameter attribute that some Pascal
>   dialects support.

Yes, but ``&const'' means ``constant reference'' and every reference is a constant
anyway since you cannot change its ``value''; that is, you cannot make it denote
a different object. Had there been a re-initialization operation for references
it would have made sense.

Anyway, what you were trying to seay was ``reference to constant object'' not
``constant reference to object''. This is how:

	fred(const gorf& g);

I am personally nervous about programs where reference arguments are used
extensively and wished I had used ``reference to constant'' systematically
in the book. Arguments of ``reference to constant'' type provide a safe
and efficient way of passing large chunks of information; like ``by value'',
but with less copying.

	- Bjarne Stroustrup (AT&T Bell Labs, Murray Hill)
Technical Details
Message-ID: <5132@alice.uUCp>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!alice!bs

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!alice!bs
From: bs@alice.UucP (Bjarne Stroustrup)
Newsgroups: net.lang.c++
Subject: some small questions
Message-ID: <5132@alice.uUCp>
Date: Wed, 19-Mar-86 10:42:58 EST
Article-I.D.: alice.5132
Posted: Wed Mar 19 10:42:58 1986
Date-Received: Fri, 21-Mar-86 05:29:13 EST
Organization: Bell Labs, Murray Hill
Lines: 45