P
Paul
The entity I indexed with the expression array[-1][3], wtf do you think iJames Kanze said:I have this array:int (*array)[4] = new int[4][4];
++array;
array[-1][3] = 4;Is this an array? Or is it not an array?
Is what an array or not?
mean?
What you allocated is an array. The
variable "array" is a pointer, not an array (as sizeof(array)
will clearly show).
Also I have another array:int* arr1 = new int[12];
arr1[0] = 33;
int* arr2 = new(++arr1) int[11];
std::cout<< arr2[-1];
I'm not sure, but I think that last line has undefined behavior.
The array new operator returns a pointer to the *first* element
of an array.
Its not undefined at all, it's defined in the C++ standard as :
*((arr2)+(-1))
Again, is what an array or just a pointer.
Again, the entity I indexed with the expression arr2[-1], wtf do you think?
So you think that when I index the array with arr2[-1], I do not index anAll of the named
variables in your code are pointers, not arrays.
array?
Strange how it seems to return the correct values ..hmmm
No it can point to an array. The C++ standard clearly states that :An int* is a pointer. It may point to the first element of an
array (or anywhere inside an array, for that matter), but it is
and remains a pointer to a single int.
"the newexpression yields a pointer to the initial element (if any) of the
array. [Note: both new int and new int[10] have type int* and the type of
new int[10] is int (*)[10]. ]"
Strange how you seem to have changed colors on this , it doesn't seem that
long ago that I stuck in to support you when you were having the exact same
argument with Leigh. And you said
Voila! when I posted code to support you.