mercredi 11 août 2021

Why should I initialize data members on declaration (not necessary on constructor)?

Does anyone could explain me the reason of this coding recommendation ?

Since C++11, please initialize data members on declaration (not necessary on constructor) :

class Limit
{
public:
    Limit() = default;

private:
    int32_t quantity = 0;
    double  price    = 0.0;
};

Aucun commentaire:

Enregistrer un commentaire