From -2552583201354735218
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,64f01d1ff808466e
X-Google-Attributes: gidf78e5,public
From: James Kanze <james-albert.kanze@vx.cit.alcatel.fr>
Subject: Re: Constructor with no argument???
Date: 1997/04/25
Message-ID: <rf5d8rjqw9w.fsf@vx.cit.alcatel.fr>#1/1
X-Deja-AN: 237304564
References: <2.2.32.19970422174844.002fad28@central.beasys.com>
X-Original-Date: 25 Apr 1997 11:36:27 +0200
Organization: -
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBM2DIAuEDnX0m9pzZAQEYsAF/eQhb5Gf/39L8TEnGVG0Gp2TVIqV4FDfF Av39779uJt6MVkeq7iVmga9p6XBzV+l1 =nMTp
Newsgroups: comp.std.c++
Originator: fjh@mundook.cs.mu.OZ.AU


David R Tribble <david.tribble@central.beasys.com> writes:

|>  Now consider what supplying an initial value, i.e., invoking the default
|>  constructor, for these two built-in types looks like:
|>  
|>      ip = new int(i);            // Creates an int initialized to i
|>      str = new char[20]("I'm just a gigolo");
|>                                  // Creates an initialized char array
|>  
|>  (I'm not completely sure of the second line, but it seems to follow
|>  the rules.)

You're right not to be sure.  You cannot provide an initializer for
array types.  According to 5.3.4/14, the only types which can have
initializers are class, arithmetic, enumeration, pointer or pointer to
member types.  The special rules pertaining to using a string literal to
initialize an array don't apply here, either.

-- 
James Kanze      home:     kanze@gabi-soft.fr        +33 (0)1 39 55 85 62
                 office:   kanze@vx.cit.alcatel.fr   +33 (0)1 69 63 14 54
GABI Software, Sarl., 22 rue Jacques-Lemercier, F-78000 Versailles France
	    -- Conseils en informatique industrielle --
---
[ 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                             ]



