I'm learning C++ and I have a doubt about arrays (I'm still studying the topic, some things are clear,while others still seem a bit obscure to me). I would like to know whether these declarations are legal and if so, how do they affect the newly created array:
let's assume I want to create an array of ints (to keep it simple) :
I know the following is legal
int array[size];
where size is a constant expression
and this
const int array[size];
this declaration means I can read-access the elements in the array but I cannot assign to them ( int a=array[2]
is legal, array[1]=10
is an error ).
what about a "top level" const like
int const array[size];
or
const int const array[size];
are they legal in the first place? and if so, what do they mean? isn't an array constant by itself, being it impossible to assign to an array or to copy-initialize one?
thanks!
edit:
I know what "top level" and "low level" const means (though I learned that I can put the const qualifier before and after the base type specifier and that doesn't change anything). What I do want to know is how defining a const array ( and I mean not an array of const objects or variables) changes things.