lundi 31 août 2015

object initialzation before initialization list [duplicate]

This question already has an answer here:

given:

class A {
    std::list<int> m_list;
    std::list<int>::iterator m_iterator;
public:
    explicit A() : m_iterator(m_list.begin()) { }
};

Am I guaranteed m_list will be constructed before evaluating ctor initialization list, so that a begin() will correctly dereference its beginning/end? Or should I better use an m_iterator assignment inside ctor body?

Aucun commentaire:

Enregistrer un commentaire