mardi 26 avril 2016

Default initialization of buillt-in members

On Bjarne Stroustrup's The C++ Programming Language, 4th Edition, 17.6.3.1 it is stated that

The ‘‘default initialization’’ of a built-in member leaves that member uninitialized.

referring to the default compiler generated constructor.

However, in 17.6.2 we have the following code

struct S {
  string a;
  int b;
};

S f(S arg)
{
  S s0 {};     // default construction: {"",0}
..
}

where b is default initialized to 0.

So, what am I missing here ?

Aucun commentaire:

Enregistrer un commentaire