I have a class A that takes an initializer_list and saves it as a member variable.
class A { public: A(std::initializer_list<std::string> il) : m_il(il) {} std::initializer_list<std::string> m_il; };
Another class B has A as a member variable, which is initialized by default with initializer_list
class B { public: B() { std::cout << *m_a.m_il.begin() << std::endl; } A m_a { "hello", "bye" }; };
Now when I run this code basically, it doesn't print anything.
int main() { B b; }
Why didn't the code above print hello ? Is using std::initializer_list wrong?
c ++ c ++ 11
tcb
source share