+ 1

Why initializer_list is not working

Hi I tried to implement queue using two stacks and it works fine as below: https://code.sololearn.com/cg5Iz87Ve3AC My query is related to initializer list. Why below code fails even though a constructor with initializer list is provided for myQueue class? //myQueue q1 {1, 2, 3};

12th Mar 2022, 6:08 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Respuesta
+ 4
Pass the std::initializer_list by value or const ref, though pass by value is preferred for an initializer_list since it's very cheap.
12th Mar 2022, 9:43 PM
Dennis
Dennis - avatar