vendredi 25 décembre 2015

c++11 initializing data members

I just installed VS2015 and finally I get c++11 support. I wonder if people use the new way of initializing data members like so

class C {
public:
    void print() {
        cout << i << "\n";
    }
private:
    int i = 3;
};

I first hated the initialization list concept when I learned it and my thoughts were "why can't I just initialize data members on the fly". Well now I can and it feels weird! Is it good practice?

Aucun commentaire:

Enregistrer un commentaire