From 1273409793591702285
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,5e69b3c02624e7d0
X-Google-Attributes: gidf78e5,public
From: AllanW <allan_w@my-deja.com>
Subject: Re: A C++ asymmetry
Date: 1999/09/14
Message-ID: <7rkj53$r8q$1@nnrp1.deja.com>#1/1
X-Deja-AN: 524884032
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <yfHaNyPjoGWxa6bbbTdKITIXiWzP@4ax.com> <37DD1C53.4DAF6B25@sensor.com>
X-Snookums: I love you
X-Original-Date: Tue, 14 Sep 1999 04:32:35 GMT
X-Http-User-Agent: Mozilla/4.08 [en] (WinNT; I)
X-Complaints-To: news@news.unimelb.edu.au
X-Http-Proxy: 1.0 PROXY_2, 1.0 x25.deja.com:80 (Squid/1.1.22) for client 204.140.188.5
X-Trace: ariel.ucs.unimelb.edu.au 937305406 16895 128.250.37.153 (14 Sep 1999 10:36:46 GMT)
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Tue Sep 14 04:32:35 1999 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN94lMeEDnX0m9pzZAQHacwGAl7hJLPH8XCWFmzgKD9kbR4UuoFXERV7Y UzDEUdkqcaMxV2AzBUvLclk8C6iGzYW/ =9v1g
X-MyDeja-Info: XMYDJUIDallan_w
NNTP-Posting-Date: 14 Sep 1999 10:36:46 GMT
Newsgroups: comp.std.c++

In article <37DD1C53.4DAF6B25@sensor.com>,
  Ron Natalie <ron@sensor.com> wrote:

> ... It might have been nice to either make an exception for
> the copy constructor, or to also inhibit the copy constructor
> in this case, but I think it was found that in most
> cases the behavior as specified fits the most common
> situations.

I disagree. I have found that the automatically-created
copy constructor is one of the biggest sources of errors.

Beginning programmers don't know that the compiler does
this; every month or two someone posts a question to
comp.std.c++ asking why his constructor fires twice but
the destructor fires three times (for instance, when
returning an object by value) and we have to explain copy
constructors to him.

More experienced programmers simply forget to define the
copy constructor, or else they add a second parameter
and forget to supply a default value. Once again, the
compiler's "helpful" version steps in.

In my opinion, the way that the rule should have worked is,
if the programmer doesn't provide any constructors then the
compiler will. But if the programmer defines even one
constructor, then there are no implicit ones.

...not that I expect this rule to change during my lifetime...

--
Allan_W@my-deja.com is a "Spam Magnet," never read.
Please reply in newsgroups only, sorry.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



