mercredi 7 janvier 2015

C++ uniform initialization with default values

Considering following structs:



struct A
{
int i;
};

struct B
{
int i = 0;
};


Why I can initialize objects of type A using uniform initializers and I can't initialize objects of type B?



A a{1};
B b{1}; //ill formed


What is the compiler doing when a default value is used to initialize members?


Aucun commentaire:

Enregistrer un commentaire