Use new operator to initialise an array

In the new Standard for C++ (C++11), you can do this:

int* a = new int[10] { 1,2,3,4,5,6,7,8,9,10 };

It’s called an initializer list. But in previous versions of the standard that was not possible.

The relevant online reference with further details (and very hard to read) is here. I also tried it using GCC and the --std=c++0x option and confirmed that it works indeed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)