Monday, July 10, 2017

C++11: Initializer lists

You can get the size of an initializer list with the size() member function. Here is an example:
#include
#include
using namespace std;

int main()
 {
    initializer_list myInitializer_List;
    myInitializer_List = {10, 11, 12};
    cout << myInitializer_List.size() << endl;
    return 0;
}
// output: 3


No comments:

Post a Comment