From -1458123445469757506
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,5e69b3c02624e7d0
X-Google-Attributes: gidf78e5,public
From: sbnaran@uiuc.edu (Siemel B. Naran)
Subject: Re: A C++ asymmetry
Date: 1999/09/13
Message-ID: <slrn7tnubc.7vt.sbnaran@localhost.localdomain>#1/1
X-Deja-AN: 524537831
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <yfHaNyPjoGWxa6bbbTdKITIXiWzP@4ax.com>
X-Original-Date: 12 Sep 1999 19:13:18 GMT
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: ariel.ucs.unimelb.edu.au 937242968 24680 128.250.37.153 (13 Sep 1999 17:16:08 GMT)
Organization: University of Illinois at Urbana-Champaign
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN90xRuEDnX0m9pzZAQHS+QF9FsOfNQ+EEqd0vsD0xl+FrpOxytGEqSbY MFouSdxQoFHYUSLQEooA22/ajlBHCohE =Hi49
User-Agent: slrn/0.9.5.7 (UNIX)
Reply-To: sbnaran@uiuc.edu
NNTP-Posting-Date: 13 Sep 1999 17:16:08 GMT
Newsgroups: comp.std.c++

On 12 Sep 1999 14:53:59 GMT, Aldo Aleardi <aldo.a@interplanet.it> wrote:

>If I define a default constructor and no copy constructor, the
>standard says that a default copy constructor is implicitly defined,
>so this code is well-formed

>but if I define a default copy constructor and no default constructor
>the standard says that a default constructor will not be implicitly
>defined, so the following code will not compile:

Here is a guess.

Most objects need a copy constructor, so one is implicitly defined.
The implicit constructor usually does the right thing -- ie, applies
the copy constructor for each of the sub-objects.

A default constructor should never be implicitly generated, but for
backward compatibility with C -- ie, a struct is basically a class
with all members public -- the compiler will create one.  Example,
given "struct S { std::vector<int> v; int i; };" the compiler
creates a S::S().

-- 
--------------
siemel b naran
--------------
---
[ 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              ]



