I found out accidentally that the following code is only supported in the c++0x standard...thus giving a gcc option "-std=c++0x" ....compiles it without problems..
The three values in x are ...as expected 1,2 and 3.Code:int x[3]; x = {1,2}; x[2]=3;
But when "int x[3];" is replaced by
..the error message "error: cannot convert <brace-enclosed initializer list> to int* in assignment " is displayed.Code:int *x; x = new int[3];
Why does it happen?..
also is there a way around this ?..i.e. I want the array dynamically allocated....
also Does the STL define such a container to make something similar possible?(in that case I'd like to assign ..say..3 arbitrary values to three of its elements in a single statement. )