pointer to array types

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.
 
P

Paul

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.

I was obviously talking about using a pointer to access data of the old
data-type.


--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.

Good I don't need nor do I wnat your help TYVM, Goodbye and GL
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top