In C++11, we have two ways to initialize the data members of a class/struct as illustrated in the following examples:
struct A
{
int n = 7;
};
struct B
{
int n;
B() : n(7) {}
};
Question 1:
Which way is better?
Question 2:
Is the traditional way (the latter) not encouraged from the view of a modern-C++-style checker?
Aucun commentaire:
Enregistrer un commentaire