Extended initializer lists only available with -std=c++0x or -std=gnu++0x

You may get error "Extended initializer lists only..." while you are compiling your C++ code. This error is encountered when you are trying to assign the elements of the array as:
     array[10]={9,8,7,6,5,4,3,2,1,0};

Which you have already declared some where in your code as
    int array[10];  

You can only specify the initialization list during declaration of the array hence the error, if you want to assign the values somewhere else in your code except declaration then use the for loop or direct assignment at particular index such as
    for(int i =0; i< 10; ++i)
        array[i] = value;
or
    array[0] = value0;
    .
    .
    .
    array[9] = value9;
   

Hope this helps...

No comments:

Post a Comment

Golang: Http POST Request with JSON Body example

Go standard library comes with "net/http" package which has excellent support for HTTP Client and Server.   In order to post JSON ...