In previous version of C++ standard (C++03) we was able to do following array elements assignment: But we have not been able to do similar assignments to vector : In order to assign above three elements to vector we had to invoke push_back () method three times: C++11 present feature which help with above inconvenience. This feature can be achieved thanks to initializer_list template. In C++11, vector implementation has assignment operator taking initializer_list template as parameter: Thanks to that we can use following assignments to vector : The same way we can overload assignement operator of any of own class, as well as constructor or any function. Such definition can can take initializer_list template as parameter. Then we will be able to pass initialization list having syntax: { element1, element2, element3,...} as parameter of such function. Of course STL vector container has implemented constructor having initializer_list as parameter, too. So you can also...
Articles based on my software engineering adventure