The following code works with GCC’s C compiler, but not with the C++ compiler. Is there a “shortcut” to achieve the same result in C++?
int array[10] = {
[1] = 1,
[2] = 2,
[9] = 9
};
EDIT:
Humm, I found this, clarifies everything.
http://eli.thegreenplace.net/2011/02/15/array-initialization-with-enum-indices-in-c-but-not-c/
This form of initialization is only defined in the C99 standard. It does not apply to C++. So, you’ll have to assign your elements one-by-one: