mercredi 15 avril 2015

Explicitly defaulted constructors and initialisation of member variables

I'm slightly confused about what happens when a ctor is explicitly defaulted.


Are the two code samples below equivalent?


Are there any constraints on Y to be able to use the first option?



class X
{
public:
X() = default;

private:
Y m_y;
};

class X
{
public:
X() : m_y() {}

private:
Y m_y;
};

Aucun commentaire:

Enregistrer un commentaire