F
Fred Zwarts
Paul said:If you use the union as a float the memory location does not contain
an array.
--According to your reasoning,
--IntPointer would be also a pointer to a float,
--and to a float array, etc. etc.
No, when the union chnages to represent a new data-type the pointer to
the old data-type is no longer valid IMO.
Your confusion leads you to wrong conclusions.
The pointer can still be used to assign an int value to x.Integer.
*IntPointer = 3;
So, it remains a valid pointer to int, even if the object at the memory
location is a float.
I'm not confused at all by your scenraio.
--That is right. Your wrong conclusion does not come from my scenario,
--but from your ideas about pointers that are incompatible with the C++
--language.
If you think p does not point to an array then I think you'll find that
it's you who is wrong.
int*p = new int[3];
--If you think that the pointer to the old data-type is no longer valid,
--it is you who is wrong.
--*IntPointer = 3;
I didn't say the pointer was invalid. I said the pointer points-to the
union no matter what type the pointer was.
And you have just proved this is correct.
First Paul said (See above):
Now Paul summarizes:
I didn't say the pointer was invalid.
Sorry, I'm unable to find the logic in this language.
If "no longer valid" is the same as "not invalid", anything can be true.
This makes it impossible for me to help him any further.