Hello everybody!
Can you explain the different between these things?
int a[7] = {a[0] = 1, a[6] = 1};
int a[7] = {[0] = 1, [6] = 1};
int a[7] = {a[0] = a[6] = 1};
by the first method the values of array will be (1,1,0,0,0,0,0)
by the second method - {1,0,0,0,0,0,1}
by the third method - {1,0,0,0,0,0,0}
Why? I can't understand anything!
Because you don't initialize arrays like that.
method 2 shouldn't compile at all
method 1 assigns to the first and the second elements the values of the expressions a[0] = 1 and a[6] =1 and 0 to all other elements
method 3 assigns to the first element the value of the expression a[0] = a[6] = 1 and 0 to the others http://www.cplusplus.com/doc/tutorial/arrays/
Thanks. Finally there is C++ equivalent to Java syntax!
But I notice why below does not compile.
char[] p = {'0','1'};
Is the placement of the square brackets important ? Maybe I toggle between Java and C++ and sometimes I get confused cuz I do both language implementation.