P
Paul
Leigh Johnston said:On 18/03/2011 22:55, Paul wrote:Only pointers of an array type point to an array of said type.
Only pointers of an array type return an array of data when
dereferenced.
Err no
A pointer of type int(*)[10] doesn't point to an array of type
int[10], it
points to an array of type int[10];
I said, "said type". You have changed my statement based on what is
going on in your head.
At least you are starting to use proper terminology, so progress has
been made.
A pointer of type int(*)[10], also the same as int[10]*, points to
an
array of 10 int.
No you are wrong. it points to an array of type int[10].
When it's dereferenced it points to an array of int[10] type.
When a pointer of type int(*)[10] is dereferenced the result is not a
pointer so it doesn't point to anything; the result of the dereference
is a reference of type int[10].
int (*x)[10] = new int[3][10];
If x is dereferenced like so ...x[0] , x is converted to a pointer to
int[10]. This means x is not a pointer to int[10] to begin with.
It's a pointer to int[3][10].
Wrong; x is not converted to a pointer to int[10] as it is *already* a
pointer to int[10]; x[0] is a reference to an int[10] array as
sizeof(x[0]) will confirm.
int x[3][5];
Here x is a 3 × 5 array of ints; more precisely, x is an array of three
element objects, each of which is an array of five ints. In the
expression x, which is equivalent to (*((x)+(i))), x is first
converted to a pointer to the initial array of five ints.
It cannot be any clearer than that.
Yes that part of the standard is quite clear; I am not sure why you are
quoting it though as nobody has contradicted it as we are talking about
something different. An array is not a pointer; the Standard's
description of what happens (or an equivalence of what happens) when
subscripting an array does not invalidate this axiom.
It confirms what you said is complete and utter bollocks ref:
</quote>Wrong; x is not converted to a pointer to int[10] as it is *already* a
pointer to int[10]; x[0] is a reference to an int[10] array as
sizeof(x[0]) will confirm.
The C++ standards directly contradict what you think.