delete[] p or delete[] *p

P

Paul

Peter Remmers said:
Am 08.04.2011 19:09, schrieb Paul:
Consider this:

int aa[2][2]; int* p=aa[0];

...
With the above p points to an array , you think it only points to a
single int. You do not have any consideration for what is pointed to
,
you incorrectly think the pointer type defines what is pointed to.

Is it correct that in your opinion, in the above example,
the pointer p points to all of
1) aa[0][0] ,
2) aa[0] and
3) aa
?

I don't care what it points to
You are so annoying. You just go on and emit your attitude crap when
challenged.
You're annoying for being wrong.
That's totally irrelevant. The question's purpose was to clarify your
position. Even though you constantly promulgate your ultimate truths and
fulminate at everyone who disputes them, you can't stand by your position
when directly asked? You make me sick.

My position cannot be any clearer, you make me sick.
You are unable to answer a simple question.
You evade by deflecting the question.
And what question can't I answer?
I think it points to the int lvalue aa[0][0].
What do you think it points to?
I think it poiints to a section of memory.

You are unable to answer a simple question.
You evade by using dummy answers.
No I answered it correctly. You obviously have a problem with all things
that are correct.
 
P

Paul

Leigh Johnston said:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I do know what it points to. Saying that I am confused is a (obviously
false) premise. Kindly explain what is wrong in my logic.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You don't know what this points to:
int* p = new int[6];

With the above p points to an array , you think it only points to a
single
int. You do not have any consideration for what is pointed to , you
incorrectly think the pointer type defines what is pointed to.

That's not the explanation, that's an assertion, and it's false.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You have made your opinion, that a pointer-type always defines what is
pointed to, very clear.
I haven't asserted anything , you have provided this evidence. If it's
false
then it's your opinion that's false, not mine

Yes you have. All you have are assertions. Not even opinions, plain
assertions. The "Martians exist, my dad saw them!" kind.

Explain how it is possible that both pointer points to an array, and
incrementing it makes it point to the next ___element in the array__.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Explain how what is possible?
I'm sorry but what you say is unclear.

He is quite clear. Explain how incrementing a pointer to an array will
make the pointer point to the next element in the array? It can't as it is
not a pointer to an array but a pointer to an array element; if it was a
pointer to an array incrementing it would make it point to the next array
not the next array element.
Sorry I dont understand your idiot mind either. You don't understand how to
increment a pointer to an array?
 
P

Peter Remmers

Am 08.04.2011 20:45, schrieb Paul:
Peter Remmers said:
Am 08.04.2011 19:09, schrieb Paul:
Consider this:

int aa[2][2]; int* p=aa[0];

...
With the above p points to an array , you think it only points to a
single int. You do not have any consideration for what is pointed to
,
you incorrectly think the pointer type defines what is pointed to.

Is it correct that in your opinion, in the above example,
the pointer p points to all of
1) aa[0][0] ,
2) aa[0] and
3) aa
?

I don't care what it points to
You are so annoying. You just go on and emit your attitude crap when
challenged.
You're annoying for being wrong.
Wrong about what? About you being annoying? I don't think so.
My position cannot be any clearer, you make me sick.
Then why can't you answer a simple question? It was even a yes-or-no
question. Even *you* should be able to type two-letter and three-letter
words.
And what question can't I answer?
You are unable to answer a simple question.
You evade by pretending you are unaware of any question.

You are playing dumb just to be annoying, aren't you?
I think it points to the int lvalue aa[0][0].
What do you think it points to?

I think it poiints to a section of memory.

You are unable to answer a simple question.
You evade by using dummy answers.
No I answered it correctly. You obviously have a problem with all things
that are correct.

You deny that it is a dummy answer?


Peter
 
P

Paul

Peter Remmers said:
Consider this:

int aa[2][2]; int* p=aa[0];

...
With the above p points to an array , you think it only points to
a
single int. You do not have any consideration for what is pointed
to
,
you incorrectly think the pointer type defines what is pointed
to.

Is it correct that in your opinion, in the above example,
the pointer p points to all of
1) aa[0][0] ,
2) aa[0] and
3) aa
?

I don't care what it points to
You are so annoying. You just go on and emit your attitude crap when
challenged.
You're annoying for being wrong.
Wrong about what? About you being annoying? I don't think so.
You are just wrong about everything. You are just a wrong person in all
honesty.
Then why can't you answer a simple question? It was even a yes-or-no
question. Even *you* should be able to type two-letter and three-letter
words.
I did answer the question, please stop being wrong.
You are unable to answer a simple question.
You evade by pretending you are unaware of any question.

You are playing dumb just to be annoying, aren't you?
No you are the one who fits the adjective "dumb" here, not I.
I think it points to the int lvalue aa[0][0].
What do you think it points to?

I think it poiints to a section of memory.

You are unable to answer a simple question.
You evade by using dummy answers.
No I answered it correctly. You obviously have a problem with all things
that are correct.

You deny that it is a dummy answer?
The only dummy here is you, the answer I gave is 100% correct.
 
P

Paul

Leigh Johnston said:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I do know what it points to. Saying that I am confused is a
(obviously
false) premise. Kindly explain what is wrong in my logic.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You don't know what this points to:
int* p = new int[6];

With the above p points to an array , you think it only points to a
single
int. You do not have any consideration for what is pointed to , you
incorrectly think the pointer type defines what is pointed to.

That's not the explanation, that's an assertion, and it's false.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You have made your opinion, that a pointer-type always defines what is
pointed to, very clear.
I haven't asserted anything , you have provided this evidence. If it's
false
then it's your opinion that's false, not mine

Yes you have. All you have are assertions. Not even opinions, plain
assertions. The "Martians exist, my dad saw them!" kind.

Explain how it is possible that both pointer points to an array, and
incrementing it makes it point to the next ___element in the array__.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Explain how what is possible?
I'm sorry but what you say is unclear.

He is quite clear. Explain how incrementing a pointer to an array will
make the pointer point to the next element in the array? It can't as
it is not a pointer to an array but a pointer to an array element; if
it was a pointer to an array incrementing it would make it point to
the next array not the next array element.
Sorry I dont understand your idiot mind either. You don't understand how
to increment a pointer to an array?

There is not much we can do if you cannot (or will not) understand the
basics.
Correct I do not understand your basic idiot mind.

However I do understand how to increment a pointer to an array, which
obviously you find challenging.
 
P

Peter Remmers

Am 08.04.2011 22:08, schrieb Paul:
Peter Remmers said:
Consider this:

int aa[2][2]; int* p=aa[0];

...
With the above p points to an array , you think it only points to
a
single int. You do not have any consideration for what is pointed
to
,
you incorrectly think the pointer type defines what is pointed
to.

Is it correct that in your opinion, in the above example,
the pointer p points to all of
1) aa[0][0] ,
2) aa[0] and
3) aa
?

I don't care what it points to
You are so annoying. You just go on and emit your attitude crap when
challenged.
You're annoying for being wrong.
Wrong about what? About you being annoying? I don't think so.
You are just wrong about everything. You are just a wrong person in all
honesty.
Hm yeah. The universal insult. That's.... childish. Try to be less childish.
I did answer the question, please stop being wrong.

By using a dummy answer. That's... childish. Try to be less childish.
No you are the one who fits the adjective "dumb" here, not I.
Hm yeah. Deflecting adjectives. That's... childish. Try to be less childish.
I think it points to the int lvalue aa[0][0].
What do you think it points to?

I think it poiints to a section of memory.

You are unable to answer a simple question.
You evade by using dummy answers.

No I answered it correctly. You obviously have a problem with all things
that are correct.

You deny that it is a dummy answer?
The only dummy here is you, the answer I gave is 100% correct.

Hm yeah. Deflecting nouns. That's... childish. Try to be less childish.

It was a decoy answer. Correct but too trivial to be a serious answer.
Only trying to distract from your inability to really answer this simple
question. Try to be less childish.


Peter
 
G

Goran

Explain how it is possible that both pointer points to an array, and
incrementing it makes it point to the next ___element in the array__.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Explain how what is possible?
I'm sorry but what you say is unclear.

No, it's clear enough, and you are lying when saying it's not. If you
say that pointer of type "T*" (somehow, sometime, whatever) points to
an __array__ of T, then simplest of pointer operations (indexing,
incrementing) are broken.

Since pointer operations clearly aren't broken, your claim is false.

Goran.
 
P

Paul

Explain how it is possible that both pointer points to an array, and
incrementing it makes it point to the next ___element in the array__.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Explain how what is possible?
I'm sorry but what you say is unclear.

No, it's clear enough, and you are lying when saying it's not. If you
say that pointer of type "T*" (somehow, sometime, whatever) points to
an __array__ of T, then simplest of pointer operations (indexing,
incrementing) are broken.

Since pointer operations clearly aren't broken, your claim is false.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is broken about indexing and incrementing?
I don't know what you are talking about, it works fine on my system, please
explain.
 
G

Goran

No, it's clear enough, and you are lying when saying it's not. If you
say that pointer of type "T*" (somehow, sometime, whatever) points to
an __array__ of T, then simplest of pointer operations (indexing,
incrementing) are broken.

Since pointer operations clearly aren't broken, your claim is false.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is broken about indexing and incrementing?

int a[2][2]={1,2,3,4};
int* p1 = a[0]; // p1 points to an array (your claim).
p1++;
if (*p1 != a[1])
std::cout << "incrementing is broken.";
int* p2 = a[0]; // p2 points to an array (your claim).
if (*p2[1] != a[1])
std::cout << "indexing is broken.";

Goran.
 
P

Paul

No, it's clear enough, and you are lying when saying it's not. If you
say that pointer of type "T*" (somehow, sometime, whatever) points to
an __array__ of T, then simplest of pointer operations (indexing,
incrementing) are broken.

Since pointer operations clearly aren't broken, your claim is false.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is broken about indexing and incrementing?

int a[2][2]={1,2,3,4};
int* p1 = a[0]; // p1 points to an array (your claim).
p1++;
if (*p1 != a[1])
std::cout << "incrementing is broken.";
int* p2 = a[0]; // p2 points to an array (your claim).
if (*p2[1] != a[1])
std::cout << "indexing is broken.";

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You create a 2d array, then you create a pointer to a 1d-subarray of this 2d
array.
Then after that I don't know what you are trying to do. You say its broken
but you don't say what you expect it to do.
It looks like you increment the pointer to the 1d-subarray and expect it to
increment the 2d array , or something stupid like that. But surely you can't
be that stupid?

What exactly is your code trying to do?
 
G

gwowen

You create a 2d array, then you create a pointer to a 1d-subarray of this2d
array.

(Specifically, the first 1d-subarray.)
Then after that I don't know what you are trying to do.

He's trying to increment the pointer to the FIRST 1d-subarray, in the
expectation that doing so will cause it to point to the SECOND 1d-
subarray. Do *you* think this should work?
 
G

Goran Pusic

No, it's clear enough, and you are lying when saying it's not. If you
say that pointer of type "T*" (somehow, sometime, whatever) points to
an __array__ of T, then simplest of pointer operations (indexing,
incrementing) are broken.
Since pointer operations clearly aren't broken, your claim is false.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is broken about indexing and incrementing?

int a[2][2]={1,2,3,4};
int* p1 = a[0]; // p1 points to an array (your claim).
p1++;
if (*p1 != a[1])
  std::cout << "incrementing is broken.";
int* p2 = a[0]; // p2 points to an array (your claim).
if (*p2[1] != a[1])
  std::cout << "indexing is broken.";

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You create a 2d array, then you create a pointer to a 1d-subarray of this2d
array.
Then after that I don't know what you are trying to do. You say its broken
but you don't say what you expect it to do.

I expect both pointers to point to a[1]. This is because you say that
they point to one array (a[0]), and I know that incrementing, or
indexing pointers with 1, must make them point to next element. Thats
a[1]. This is how pointers work. Explain why this doesn't happen.

Goran.
 
P

Paul

No, it's clear enough, and you are lying when saying it's not. If you
say that pointer of type "T*" (somehow, sometime, whatever) points to
an __array__ of T, then simplest of pointer operations (indexing,
incrementing) are broken.
Since pointer operations clearly aren't broken, your claim is false.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is broken about indexing and incrementing?

int a[2][2]={1,2,3,4};
int* p1 = a[0]; // p1 points to an array (your claim).
p1++;
if (*p1 != a[1])
std::cout << "incrementing is broken.";
int* p2 = a[0]; // p2 points to an array (your claim).
if (*p2[1] != a[1])
std::cout << "indexing is broken.";

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You create a 2d array, then you create a pointer to a 1d-subarray of this
2d
array.
Then after that I don't know what you are trying to do. You say its broken
but you don't say what you expect it to do.

I expect both pointers to point to a[1]. This is because you say that
they point to one array (a[0]), and I know that incrementing, or
indexing pointers with 1, must make them point to next element. Thats
a[1]. This is how pointers work. Explain why this doesn't happen.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Incrementing it will make it point to a[0][1] becuase you increment a
pointer to a 1d array. If you want to make it point to a[1][0] then you must
use a pointer to a 2d array like so:
int (*p)[2] = a;
p++;
/*now p points to a[1][0]*/

I don't see what you find so difficult about this.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
G

Goran

"Goran" <[email protected]> wrote in message
int a[2][2]={1,2,3,4};
int* p1 = a[0]; // p1 points to an array (your claim).
p1++;
if (*p1 != a[1])
std::cout << "incrementing is broken.";
int* p2 = a[0]; // p2 points to an array (your claim).
if (*p2[1] != a[1])
std::cout << "indexing is broken.";
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You create a 2d array, then you create a pointer to a 1d-subarray of this
2d
array.
Then after that I don't know what you are trying to do. You say its broken
but you don't say what you expect it to do.

I expect both pointers to point to a[1]. This is because you say that
they point to one array (a[0]), and I know that incrementing, or
indexing pointers with 1, must make them point to next element. Thats
a[1]. This is how pointers work. Explain why this doesn't happen.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Incrementing it will make it point to a[0][1] becuase you increment a
pointer to a 1d array.

OK. So, I'll presume then this claim is true, that int* is a pointer
to 1d array. If so (continuing from previous example)...

p1 = &a[0][1]; // 1
int i;
p1 = &i; // 2

If p is a pointer to a 1d array, how come I can assign address of a
single int to it? a[0][1] and i are clearly not arrays.

Also, if your claim is true, then in:

int aa[2];
int(*pa)[2] = &aa; // 3

pa is a pointer to a 2d array. But aa is clearly __not__ a 2d array.

Since all of 1, 2, 3 is both correct and legal code, your claim, that
T* is a pointer to 1d array of T, is false.

Goran.
 
S

SG

[...]
If p is a pointer to a 1d array, how come I can assign address
of a single int to it? a[0][1] and i are clearly not arrays.

When he says "p is a pointer to a 1d array" he means "p currently
stores an address of an array or the address of something that is part
of that array". So, when he says "p is ..." he's mainly considering
runtime properties and the raw type-agnostic address some object
pointer stores. Unlike others, he ignores the type of a pointer
variable when it comes to describing what a certain pointer "is".
That's why he brought up the broken finger/bunch/banana analogy.

Guys, don't you realize that this is going around in circles? Don't
you have anything better to do?

SG
 
P

Paul

int a[2][2]={1,2,3,4};
int* p1 = a[0]; // p1 points to an array (your claim).
p1++;
if (*p1 != a[1])
std::cout << "incrementing is broken.";
int* p2 = a[0]; // p2 points to an array (your claim).
if (*p2[1] != a[1])
std::cout << "indexing is broken.";
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You create a 2d array, then you create a pointer to a 1d-subarray of
this
2d
array.
Then after that I don't know what you are trying to do. You say its
broken
but you don't say what you expect it to do.

I expect both pointers to point to a[1]. This is because you say that
they point to one array (a[0]), and I know that incrementing, or
indexing pointers with 1, must make them point to next element. Thats
a[1]. This is how pointers work. Explain why this doesn't happen.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Incrementing it will make it point to a[0][1] becuase you increment a
pointer to a 1d array.

OK. So, I'll presume then this claim is true, that int* is a pointer
to 1d array. If so (continuing from previous example)...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Its not a claim its a fact.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

p1 = &a[0][1]; // 1
int i;
p1 = &i; // 2

If p is a pointer to a 1d array, how come I can assign address of a
single int to it? a[0][1] and i are clearly not arrays.

Also, if your claim is true, then in:

int aa[2];
int(*pa)[2] = &aa; // 3

pa is a pointer to a 2d array. But aa is clearly __not__ a 2d array.

Since all of 1, 2, 3 is both correct and legal code, your claim, that
T* is a pointer to 1d array of T, is false.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Whether your code is legal or valid , I don't care but it certainly doesn't
look right to me.
Believe what you want on this subject I have explained enough and if you
still do not understand then IDC.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
P

Paul

SG said:
[...]
If p is a pointer to a 1d array, how come I can assign address
of a single int to it? a[0][1] and i are clearly not arrays.

When he says "p is a pointer to a 1d array" he means "p currently
stores an address of an array or the address of something that is part
of that array".
No I mean p points, primarily to an array.
So, when he says "p is ..." he's mainly considering
runtime properties and the raw type-agnostic address some object
pointer stores.
A pointer stores an address of an entity. A pointer needs to be treated as
if it points-to the entity which it was created and initialised to point to.
Unlike others, he ignores the type of a pointer
variable when it comes to describing what a certain pointer "is".
That's why he brought up the broken finger/bunch/banana analogy.
No I acknowledge what type of pointers I use.
Guys, don't you realize that this is going around in circles? Don't
you have anything better to do?
Like you obviously do?
 
G

Goran

No, it's clear enough, and you are lying when saying it's not. If you
say that pointer of type "T*" (somehow, sometime, whatever) points to
an __array__ of T, then simplest of pointer operations (indexing,
incrementing) are broken.
Since pointer operations clearly aren't broken, your claim is false..
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is broken about indexing and incrementing?
int a[2][2]={1,2,3,4};
int* p1 = a[0]; // p1 points to an array (your claim).
p1++;
if (*p1 != a[1])
std::cout << "incrementing is broken.";
int* p2 = a[0]; // p2 points to an array (your claim).
if (*p2[1] != a[1])
std::cout << "indexing is broken.";
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You create a 2d array, then you create a pointer to a 1d-subarray of
this
2d
array.
Then after that I don't know what you are trying to do. You say its
broken
but you don't say what you expect it to do.
I expect both pointers to point to a[1]. This is because you say that
they point to one array (a[0]), and I know that incrementing, or
indexing pointers with 1, must make them point to next element. Thats
a[1]. This is how pointers work. Explain why this doesn't happen.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Incrementing it will make it point to a[0][1] becuase you increment a
pointer to a 1d array.

OK. So, I'll presume then this claim is true, that int* is a pointer
to 1d array. If so (continuing from previous example)...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Its not a claim its a fact.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Ok, so it's a fact that it's a pointer to an array. And one can assign
address of a single int to it, too (that's a fact, too). So pointer is
now not a pointer to an array. Therefore, your fact is in conflict
with itself. Therefore, your fact is nonsense.

Goran.
 
P

Paul

No, it's clear enough, and you are lying when saying it's not. If
you
say that pointer of type "T*" (somehow, sometime, whatever) points
to
an __array__ of T, then simplest of pointer operations (indexing,
incrementing) are broken.
Since pointer operations clearly aren't broken, your claim is false.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What is broken about indexing and incrementing?
int a[2][2]={1,2,3,4};
int* p1 = a[0]; // p1 points to an array (your claim).
p1++;
if (*p1 != a[1])
std::cout << "incrementing is broken.";
int* p2 = a[0]; // p2 points to an array (your claim).
if (*p2[1] != a[1])
std::cout << "indexing is broken.";
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You create a 2d array, then you create a pointer to a 1d-subarray of
this
2d
array.
Then after that I don't know what you are trying to do. You say its
broken
but you don't say what you expect it to do.
I expect both pointers to point to a[1]. This is because you say that
they point to one array (a[0]), and I know that incrementing, or
indexing pointers with 1, must make them point to next element. Thats
a[1]. This is how pointers work. Explain why this doesn't happen.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Incrementing it will make it point to a[0][1] becuase you increment a
pointer to a 1d array.

OK. So, I'll presume then this claim is true, that int* is a pointer
to 1d array. If so (continuing from previous example)...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Its not a claim its a fact.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Ok, so it's a fact that it's a pointer to an array. And one can assign
address of a single int to it, too (that's a fact, too). So pointer is
now not a pointer to an array.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
This would be correct.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Therefore, your fact is in conflict
with itself. Therefore, your fact is nonsense.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
No your conclusion is nonsense, the same pointer can point to a single int
or and array of int. If you assign to it the address of an array, then it
points to an array. If you assign to it the address of a single int, then it
points to a single int.
A pointer can point to almost anything, it is the programmers job to know,
understand or test for what it points to. In many cases you cannot assume a
pointer is not null, so you must test for this. If a pointer is expected to
point to a single int you cannot treat it as if it points to an array. If a
pointer is supposed to point to an array of int then it should be treated as
a pointer to array, not pointer to single int.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 

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,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top