On Mar 17, 8:28 pm, "Paul" <pchris...@yahoo.co.uk> wrote:
> 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? 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.
> Is this an array or is it just a pointer?
Again, is what an array or just a pointer. All of the named
variables in your code are pointers, not arrays.
> Or as Noah says its a pointer that doesn't even point to an
> array. Surely this is pushing the limits of plain idiocy.
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.
--
James Kanze