P
Paul
A. Bolmarcich said:[snip]
What is accessed when you dereference pparr once?
The array named arr (the value &arr has been assigned to pparr).
These are two different things.
Dereferencing pparr gives you arr, that is an array-type object , not &arr.
Typeid gives a string representation of an object TYPE, not an object.Are you incapable of using a compiler to find this out?
No, I'm capable. Here is an example program.
#include <iostream>
#include <typeinfo>
int main() {
int arr[4], (*pparr)[4]=&arr;
std::cout<<"typeid(arr)"<<
((typeid(arr)==typeid(*pparr))?"==":"!=")<<
"typeid(*pparr)"<<std::endl;
std::cout<<"&arr"<<((&arr==&(*pparr))?"==":"!=")<<
"&(*pparr)"<<std::endl;
}
The output I get is
typeid(arr)==typeid(*pparr)
&arr==&(*pparr)
the results of the expressions arr and *pparr have the same type
and the same address; the results are the same object: the array
named arr.
Its not the array of integer objects, its another object. It's an array-TYPE
object which decays into a pointer.
Dereferencing pparr does not access the array of integer objects, it
accesses another object which decays into a pointer.
The array-type object can only be reperesented in a limited amount of ways :
1) typeinfo represents it as a string in the form of "int[]"
2) sizeof represents this as an integer value.
3) Almost any other operation will cause it to be converted to a pointer,
and its value will be an address.
An array-type object is not a figment of my imagination it exists in C++.
Why do you refuse to accept that there is such an entity as an array-type
object?
You are being unreasonable because you cannot accept that dereferencingI'm not unreasonable. I have answered your questions, both here and
in other posts. I have also responed to questionable statements that
you have made and have given reasons that support my claims.
pparr doesn''t actually access the array but it gives access to an
array-type object.
All that code you posted above is uneccessary bullshit to try an show things
how you want them to appear.
simply coding :
std::cout<< *pparr;
is enough to prove that dereferencing pparr doesnt access the array, it
accesses and object which decays into a pointer.
I have stated numerous times that it is an array-TYPE object. So why dont
you understand when you do :
std::cout<< typeid(*pparr).name();
An array-TYPE is displayed. It's a TYPE not an OBJECT that is displayed by
typeid. The object that arr is, is an array-type object, which decays into a
pointer to the actuall array of integer objects.
[snip]
Its consistent with **** all you arsehole.
THere is **** all that is consistent about dereferencing pparr twice and
arr
once, except that it proves they are different levels of indirection.
WHich
is what I have been telling you all along.
I have never claimed that they have the same level of indirection.
Apparently you stopped reading what I wrote at the word "consistent"
and did not read what I actually wrote what dereferencing pparr twice
and arr once both resulting in the first element of the array is
consistent with.
But we are not arguing about what dereferencing ppar twice and arr once is.
We are aguing about the fact that dereferencing pparr ONCE points a
array-type object which stores an address, and it does not access the array
of integer objects.
You claimed that there is no intermediate object and there is only one array
object, but you are incorrect. There is an array-type object and an array of
integer objects which are not stored in the same memory location They are
different entities or objects or whatever you want to call them, they are
different fucking things altogether.
Ok so what is this object that 'arr' represents , do you accept that it isThe array named arr (the value &arr has been assigned to pparr).
an array-type object( which decays into a pointer) or do you still think
it's the array of integer objects?
What I have stated is that dereferencing pparr once accesses the
array named arr in the same sense as using the identifier arr.
It doesn't access THE array, It is dereferencing a pointer to an array-type
object. It accesses an array-type object which when accessed decays into
another pointer.
Ok with the following code:
int arr[3] = {1,2,3};
int (*pparr)[3] = &arr;
std::cout<<*pparr;
If dereferencing pparr once accessed the array then it would output 1.
It doesn't because it doesn't access the array, it accesses an array-TYPE
object, which decays into another pointer.
It doesn't matter what you wrote if you're disagreeing, with what I wrote inHere is what I wrote that you silently snipped.
caps, you are wrong.
pparr is a level of indirection from arr. Dereferencing pparr
accesses an array in the same sense as using arr accesses an array,
just as given the declaration
int i, *pi = &i;
dereferencing pi accesses an int in the same sense that using i
accesses an int.
pi needs to be dereferenced twice to access the array, i needs to be , and
can only be, dereferenced once.
It is completely incorrect to suggest that, when dereferencing, they access
the array in the same way.
I am neither. I have supported my claims with quotes from the C++
standard, sample C++ programs, and assembler source generated by
a C++ compiler. What I have not done is call someone stupid or
an arsehole, as you have done.
I accept facts, such as what is actually in the C++ standard and the
output of C++ programs. I have used those as reasons that support
what I have claimed.
You don't accept the facts. You continue to claim that dereferencing pparr
accesses the array of integer objects and refuse to accept that it actually
accesses another object which is an array-type object that decays into a
pointer..