Article View: comp.std.c++
Article #3828Re: "explicit" default constructor?
From: Steve Clamage
Date: Wed, 27 Mar 1996 17:13
Date: Wed, 27 Mar 1996 17:13
31 lines
2248 bytes
2248 bytes
In article F1@cs.tu-berlin.de, Roman Lechtchinsky <wolfro@cs.tu-berlin.de> writes: >as I read the section [class.conv.ctor] of the DWP, I get the impression that >the description of converting and non-converting constructors applies to all >constructors, i.e. a constructor is either converting or non-converting. A >non-converting constructor creates an object "only where a constructor call >is explicitly indicated by the syntax". This has no implications on >constructors with more than one parameter, but what about the default >constructor? Should a default constructor call be really indicated by the >syntax and if so, how is it to be done? What if the default constructor is >declared "explicit"? A converting constructor is one which can be called with a single parameter. The default constructor isn't a converting constructor except in the case of a constructor with all parameters having default values. If a constructor has no parameters, declaring it "explicit" has no effect, since it can never be invoked for a conversion. If a constructor's parameters all have default values, it can be a converting constructor, and declaring it "explicit" prevents it from being invoked implicitly. --- Steve Clamage, stephen.clamage@eng.sun.com --- [ 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 ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<4jbqog$78i@engnews1.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<31588662.F1@cs.tu-berlin.de>Show Full Headers
Complete Article Headers
From: clamage@Eng.Sun.COM (Steve Clamage) Message-ID: <4jbqog$78i@engnews1.Eng.Sun.COM> X-Original-Date: 27 Mar 1996 16:35:28 GMT Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 27 Mar 96 17:13:16 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Re: "explicit" default constructor? Organization: Sun Microsystems Inc. References: <31588662.F1@cs.tu-berlin.de> Reply-To: clamage@Eng.Sun.COM X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMVl3S+EDnX0m9pzZAQHTIwF+JHP5x9UVfkFmatzu4c51yo3+IVzMGnPz KA98gXFoyYF5wnwLfsIf3RzEglpSrGfB =NQOp