From 7503573328794696172
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,64f01d1ff808466e
X-Google-Attributes: gidf78e5,public
From: Alexandre Oliva <oliva@dcc.unicamp.br>
Subject: Re: Constructor with no argument???
Date: 1997/04/23
Message-ID: <orybaap6jj.fsf@sunsite.dcc.unicamp.br>#1/1
X-Deja-AN: 236835099
References: <2.2.32.19970422174844.002fad28@central.beasys.com>
X-Original-Date: 23 Apr 1997 04:00:48 -0300
Organization: IC - UNICAMP - Campinas, SP, Brazil
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBM14zDUy4NqrwXLNJAQEZwQH+LLRtDTrT+GQue3oJ/62BFd1JzDHGb7AH Zdprbyct+1wlVFKXvLvwYB/zT5GqJ1cLpX8ka/IGAaXiMr4SG7G/tA== =48v7
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


David R Tribble writes:

> jrrphd@ix.netcom.com (Julie Ranier) wrote:

> 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

The default constructor is the one that is invoked without
parentheses, or with ().  If you provide an initializer, a
copy-constructor will be used.  However, since there are no
copy-constructors for arrays, you cannot initialize an array allocated
with a new expression, so the second line is actually invalid.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
Universidade Estadual de Campinas, SP, Brasil
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



