S
Stuart Golodetz
On 18/03/2011 13:44, Leigh Johnston wrote:No; "pointing to an array of squash courts" is different to "a pointer
to an array of squash courts". This subtle difference is the cause of
your misunderstanding IMO.
/Leigh
The subtle difference is between the following two definitions:
1) For p to point to x, p must contain the address of x.
2) For p to point to x, p must not only contain the address of x, p must
also be of the correct type.
Consider:
#include <iostream>
int main()
{
int a[3];
int *p = &a[0]; // or just 'a'
int (*q)[3] = &a;
std::cout << p << ' ' << q << '\n';
return 0;
}
This prints out the same value twice -- &a[0] and &a have the same
*value*, but different *type*. By definition (1), both p and q point to
a. By definition (2), only q points to a, because p's type dictates that
it points to an int.
One can define "points to" either way (indeed any way one likes), but
definition (2) highlights that there is a difference between the way in
which p and q "point to" a, whereas definition (1) does not. For the
purposes of being precise when there may be ambiguity involved,
definition (2) thus appears preferable in more formal discussion. PMMV
(Paul's mileage may vary).
Unfortunately although your description seems to describe Paul's
misunderstanding perfectly he will still disagree due to the fact that
he is troll (in addition to being clueless).
/Leigh
That hadn't been entirely lost on me Just figured I'd at least
provide some clarity for the benefit of anyone else who might happen to
be reading the thread.
Cheers,
Stu
Note, incidentally, that I'm not saying that you can't say that "p
points to a", just that it's a colloquial usage of "points to" that
fails to fully capture the subtleties involved. In informal conversation
between people who understand the context, it may be an acceptable
colloquialism. For the purposes of e.g. standards documents, it's not.
Stu