Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #14300

Re: what is the default constructor for the POD type

From "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>
Newsgroups comp.lang.c++
Subject Re: what is the default constructor for the POD type
Date 2012-02-20 00:21 +0100
Organization A noiseless patient Spider
Message-ID <jhs05n$uo2$1@dont-email.me> (permalink)
References <380648.381.1329633206448.JavaMail.geo-discussion-forums@pbeo1> <42d7bfa4-2beb-4e44-b819-8f7d4efa607c@h6g2000yqk.googlegroups.com>

Show all headers | View raw


On 19.02.2012 18:20, Goran wrote:
>
> As Alf hinted, C++ can do this:
>
> int i; // i==random memory contents. Primitive and POD types can start
> their life like this, uninitialized.
>
> and this:
>
> int i(); // i==0. This is default initialization.

Well, it would be, except that that latter is a function declaration.

It's "the most vexing parse" of C++.

However,

   int i = int();

initializes i with the int default value.

Which is not quite the same as the /formal/ term "default 
initialization" means, but near enough: it's initialization, and it's 
the default value. :-)


Cheers & hth.,

- Alf

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

what is the default constructor for the POD type Stanley Rice <heconghui@gmail.com> - 2012-02-18 22:33 -0800
  Re: what is the default constructor for the POD type "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-02-19 07:48 +0100
  Re: what is the default constructor for the POD type Goran <goran.pusic@gmail.com> - 2012-02-19 09:20 -0800
    Re: what is the default constructor for the POD type Melissa <melis@a.com> - 2012-02-19 18:44 +0100
    Re: what is the default constructor for the POD type "Asger Joergensen" <Junk@Asger-P.dk> - 2012-02-19 18:29 +0000
    Re: what is the default constructor for the POD type "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-02-20 00:21 +0100

csiph-web