crisgoogle said:
For example:
int* p = new int[100];
Creates an object of type array of 100 int, converts it to type
int*,
and stores the result in p.
Ok this is interesting, so an object of array type is created but
its
must be a temporary.
No, it's not a temporary. It's an object with dynamic storage
duration.
Can you please give an example of how to access this object, I don't
see
what this object is.
--You access it via the pointer to its first element, which was just
--handed to you:
--p[0] accesses the first element of the array object, etc.
Yes this is what I think too, but if that pointer points to only the sub
objects and not the array type object, how do we access the array type
object ?
-- What _exactly_ do you mean by "access the array type object"?
Read it from memory.
--This hardly describes "exactly" what you mean:
--Read _what_ from memory? How is "access the array type object"
--different from reading individual array elements via pointers to those
--elements? IOW, how does my answer "p[0] accesses the first element
--of the array object" NOT tell you how to "access the array type
--object"?
Read the object of array type from memory.
Does a single object of array type exist in memory ? If so how do we access
this single object, as a whole.
--All we have in the above is an (anonymous) array, and a pointer to its
--first element. There is no identifier for the array as a whole. There
--is no "array type object" independent of the array-of-int-subobjects
--itself.
Well there either is or there isn't an onject of array type.
Your initial response was to my question asking how to access this object
of
array-type.
I can't decide if you think there si an object of array type or not.
--Of course there is. The object of array type is exactly the group
--of 100 int subobjects.
--Let me clarify. The _is_ an array; it is an object of array type.
--There is _not_ an "array type object" that is _distinct_ from this
--object of array type -- as least, as best I can tell, because I've
--never seen a definition from you saying what you mean by
--"array type object" that would allow this.
As far as I can see there is no difference between the terms "array type
object" and "object of array type".
If you see a difference between those terms please enlighten me because an
"object of T type" means the same as a "T type object" , AFAICT.
So you are saying an array is an object in its own right, as well as being
an array of objects. If so I can understand that but I cannot understand how
we access this object as a whole.
Is it a non accessable object? Or, with dynamic arrays, does it even exist?
This object obviously has some differences from the array of objects, most
obviously the difference in pluralisation, ie:
Array of objects.(plural objects)
An array type object. (singular object)
So the plural objects are accessable and the sigular object is not , is it
just a concept of all the objects grouped together as one?
Its not an object that has been declared or anything, its non modifiable,
its not accessable, a there are different opinions about whether or not it
even exists.
Some people say that there is no array object, with dynamic arrays, and that
an array object is 'arr' in the following:
int arr[55];
This is an array type object because when you examine it with typeid its
type is int[55].
This makes sense because this object is non modifiable. Its also not
accessable, as an object in its own right, because any attempt to access it
yields a pointer to its first element.
That means that your explanation of an array being the collective for all
the elements in memory does not make sense because your explanation of an
array object would also exist with a dynamic array, would it not?
So you ask what is my definition of an array type object. Well I think and
array type object is an object in its own right , that represents the memory
as a whole sequence of objects.
This object is something that the compiler creates as a pointer to the first
element with some additional info that allows the size and typeinfo to be
carried with it.
I think that in memory no objects exist other than the sequence of element
objects. However given this C++ type mechanism that allows an identifier to
represent this array as a whole, we can say that the sequence of objects is
one object as a whole.
This is the only way I can see how it works with no conflicting defintions.
The only argument I have seen against this is the "an array is not a
pointer" argument, which is nonsense because I am not saying an array is a
pointer.
Many people give negative comments such as its not this or not that but they
do not produce a reasonable defintion of their own that fits all the rules ,
such as I have done.