lundi 20 juillet 2015

Best way to initialize class members?

Using the c++11 standard, I can initialize class members in two ways:

class MyClass
{
private: 
    int a = 5;
};

or

class MyClass
{
private: 
    int a;
public:
    MyClass()
    {
        a = 5;
    }
};

Is either method superior to the other for any reason, or is it more an individual style choice?

Aucun commentaire:

Enregistrer un commentaire