vendredi 29 juillet 2016

C++11 way of initializing value type member variable

What is the correct way of instantiating Bar with its default constructor?

1)

struct Foo {
  Bar bar;
};

2)

struct Foo {
  Bar bar{};
};

3)

struct Foo {
  Bar bar;

  Foo : bar(Bar()) {}
};

4)

?

Aucun commentaire:

Enregistrer un commentaire