mardi 23 février 2016

What's the reason for initializing fields inside class?

In C++ it is possible to initialize values of class's fields durectly in class, like:

class X
{
  int a = 5;
}

What's the reason for it? Where it can be useful? The default ctor does exactly the same. And it seems like I cannot initialize values with bit masks (int a : 3).

Aucun commentaire:

Enregistrer un commentaire