More support for Paul's array terminology

M

Michael Tsang

Alf said:
To be fair, it just occurred to me, as an example, that we do say "pointer
to array of pointers" and not "pointer to first element in an array of
pointers".

And now I will probably have to kill this thread...

Thanks to Ian Collins for the 'K' key tip for Thunderbird!


Cheers & hth.,

- Alf

Are you saying that if x is a "pointer to array of pointer of T", then x is to
be declared as:

T *(*x)[5];

??
 
A

Alf P. Steinbach /Usenet

To be fair, it just occurred to me, as an example, that we do say "pointer to
array of pointers" and not "pointer to first element in an array of pointers".

And now I will probably have to kill this thread...

Thanks to Ian Collins for the 'K' key tip for Thunderbird!


Cheers & hth.,

- Alf
 
J

Johannes Schaub (litb)

Michael said:
Alf said:
To be fair, it just occurred to me, as an example, that we do say
"pointer to array of pointers" and not "pointer to first element in an
array of pointers".

And now I will probably have to kill this thread...

Thanks to Ian Collins for the 'K' key tip for Thunderbird!


Cheers & hth.,

- Alf

Are you saying that if x is a "pointer to array of pointer of T", then x
is to be declared as:

T *(*x)[5];

I think that's completely unreadable. I prefer to use alias templates for
improved readability.

template<typename T> using alias = T;
alias<T*[5]> *x;
 
G

gwowen

To be fair, it just occurred to me, as an example, that we do say "pointer to
array of pointers" and not "pointer to first element in an array of pointers".

I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).
 
S

SG

T *(*x)[5];

I think that's completely unreadable.
I prefer to use alias templates for improved readability.

template<typename T> using alias = T;
alias<T*[5]> *x;

Nice. I first thought, you're making a joke.

I guess you can also declare functions like this

alias<int(int,char*)> main;

;-)

Cheers!
SG
 
P

Paul

Leigh Johnston said:
I made it clear on multiple occasions that the phrases "pointer to" and
"points to" can mean different things *if* we are being less formal (i.e.
not technically accurate):
It is perfectly acceptable to say it's a "pointer to.." . and to mean
exactly the same as "it points to", because its very slight difference is
only grammatical.

If you want to say it's "type is pointer to.." then say that , it's
inaccurate to leave out the 'type' word and assume your definition of the
term "a pointer to" always can mean is "type pointer to" because your
interpretation is a sloppy interpretation and simply a shorthand version of
saying "it's type is pointer to".
int* p = new int[42];

1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.

(1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
runtime properties (i.e. the *objects* pointed to).

If we are being more formal (i.e. technically accurate) then I would
consider (4) to be incorrect.

This is a pointer to the right hand side of the page... ---->
It's "pointer to" the rhs of the page because it "points to" the rhs of the
page.
Both terms mean exactly the same thing but are used in a slightly different
grammatical context.

You are obviously very confused by the english language. Go away and try to
find some latin quotation so you can come back and disprove me.
 
K

Keith H Duggar

I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).

I made it clear on multiple occasions that the phrases "pointer to" and
"points to" can mean different things *if* we are being less formal
(i.e. not technically accurate):

int* p = new int[42];

1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.

(1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
runtime properties (i.e. the *objects* pointed to).

If we are being more formal (i.e. technically accurate) then I would
consider (4) to be incorrect.

Enshrined in the coming Holy Standard (unless it's been changed?):

24.2.1

5 Just as a regular /pointer to an array/ guarantees that there
is a pointer value pointing past the last element of the array,
so for any iterator type there is an iterator value that points
past the last element of a corresponding sequence.

27.7.5

...

template <class charT> unspecified get_time(struct tm* tmb, const
charT* fmt);

7 Requires: The argument tmb shall be a valid pointer to an
object of type struct tm, and the argument fmt shall be a valid
/pointer to an array/ of objects of type charT with
char_traits<charT>::length(fmt) elements.

...

template <class charT> unspecified put_time(const struct tm* tmb,
const charT* fmt);

9 Requires: The argument tmb shall be a valid pointer to an
object of type struct tm, and the argument fmt shall be a valid
/pointer to an array/ of objects of type charT with
char_traits<charT>::length(fmt) elements.

lolz ... enjoy your flaming future Leigh.

KHD
 
P

Paul

Leigh Johnston said:
On 14/06/2011 08:19, gwowen wrote:

On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
(e-mail address removed)> wrote:
To be fair, it just occurred to me, as an example, that we do say
"pointer to
array of pointers" and not "pointer to first element in an array of
pointers".

I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).

I made it clear on multiple occasions that the phrases "pointer to" and
"points to" can mean different things *if* we are being less formal
(i.e. not technically accurate):

int* p = new int[42];

1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.

(1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
runtime properties (i.e. the *objects* pointed to).

If we are being more formal (i.e. technically accurate) then I would
consider (4) to be incorrect.

Enshrined in the coming Holy Standard (unless it's been changed?):

24.2.1

5 Just as a regular /pointer to an array/ guarantees that there
is a pointer value pointing past the last element of the array,
so for any iterator type there is an iterator value that points
past the last element of a corresponding sequence.

27.7.5

...

template<class charT> unspecified get_time(struct tm* tmb, const
charT* fmt);

7 Requires: The argument tmb shall be a valid pointer to an
object of type struct tm, and the argument fmt shall be a valid
/pointer to an array/ of objects of type charT with
char_traits<charT>::length(fmt) elements.

...

template<class charT> unspecified put_time(const struct tm* tmb,
const charT* fmt);

9 Requires: The argument tmb shall be a valid pointer to an
object of type struct tm, and the argument fmt shall be a valid
/pointer to an array/ of objects of type charT with
char_traits<charT>::length(fmt) elements.

lolz ... enjoy your flaming future Leigh.

KHD

lolz? So you think that both of the following are a "pointer to an
array"?

int* p1 = 0;
int (*p2)[42] = 0;

Interesting. I would have said that only p2 is a "pointer to an array".

There are no arrays. Both are pointers to nothing.
I admire your grasp of what is technically accurate and your ability to
quote from a draft ISO standard which you are assuming is infallible.
Their types do not define what they point to, only what they are capable of
pointing to.
p1 can point to an int, an array of integers, nothing.
p2 can point to an array-type object, an array of array-type objects or
nothing.
 
Ö

Öö Tiib

On 14/06/2011 08:19, gwowen wrote:
On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
(e-mail address removed)>    wrote:
To be fair, it just occurred to me, as an example, that we do say "pointer to
array of pointers" and not "pointer to first element in an array of pointers".
I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).
I made it clear on multiple occasions that the phrases "pointer to" and
"points to" can mean different things *if* we are being less formal
(i.e. not technically accurate):
int* p = new int[42];
1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.
(1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
runtime properties (i.e. the *objects* pointed to).
If we are being more formal (i.e. technically accurate) then I would
consider (4) to be incorrect.
Enshrined in the coming Holy Standard (unless it's been changed?):

    5 Just as a regular /pointer to an array/ guarantees that there
    is a pointer value pointing past the last element of the array,
    so for any iterator type there is an iterator value that points
    past the last element of a corresponding sequence.

    ...
    template<class charT>  unspecified get_time(struct tm* tmb, const
charT* fmt);
    7 Requires: The argument tmb shall be a valid pointer to an
    object of type struct tm, and the argument fmt shall be a valid
    /pointer to an array/ of objects of type charT with
    char_traits<charT>::length(fmt) elements.
    ...
    template<class charT>  unspecified put_time(const struct tm* tmb,
const charT* fmt);
    9 Requires: The argument tmb shall be a valid pointer to an
    object of type struct tm, and the argument fmt shall be a valid
    /pointer to an array/ of objects of type charT with
    char_traits<charT>::length(fmt) elements.
lolz ... enjoy your flaming future Leigh.

lolz?  So you think that both of the following are a "pointer to an array"?

int* p1 = 0;
int (*p2)[42] = 0;

Interesting.  I would have said that only p2 is a "pointer to an array"..
  I admire your grasp of what is technically accurate and your ability
to quote from a draft ISO standard which you are assuming is infallible.

That is one point where Paul is right that most of us really call
"pointer to first element of array" as "pointer to array". We don't
use constructs like "int (*p2)[42] = 0;" enough to call them with some
special name. So these are "nothing" ... we simply don't call them ...
and therefore no conflicts arise.
 
K

Keith H Duggar

On 14/06/2011 08:19, gwowen wrote:
On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
(e-mail address removed)>    wrote:
To be fair, it just occurred to me, as an example, that we do say "pointer to
array of pointers" and not "pointer to first element in an array of pointers".
I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).
I made it clear on multiple occasions that the phrases "pointer to" and
"points to" can mean different things *if* we are being less formal
(i.e. not technically accurate):
int* p = new int[42];
1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.
(1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
runtime properties (i.e. the *objects* pointed to).
If we are being more formal (i.e. technically accurate) then I would
consider (4) to be incorrect.
Enshrined in the coming Holy Standard (unless it's been changed?):
24.2.1
    5 Just as a regular /pointer to an array/ guarantees that there
    is a pointer value pointing past the last element of the array,
    so for any iterator type there is an iterator value that points
    past the last element of a corresponding sequence.
27.7.5
    ...
    template<class charT>  unspecified get_time(struct tm* tmb,const
charT* fmt);
    7 Requires: The argument tmb shall be a valid pointer to an
    object of type struct tm, and the argument fmt shall be a valid
    /pointer to an array/ of objects of type charT with
    char_traits<charT>::length(fmt) elements.
    ...
    template<class charT>  unspecified put_time(const struct tm* tmb,
const charT* fmt);
    9 Requires: The argument tmb shall be a valid pointer to an
    object of type struct tm, and the argument fmt shall be a valid
    /pointer to an array/ of objects of type charT with
    char_traits<charT>::length(fmt) elements.
lolz ... enjoy your flaming future Leigh.
KHD
lolz?  So you think that both of the following are a "pointer to an array"?
int* p1 = 0;
int (*p2)[42] = 0;
Interesting.  I would have said that only p2 is a "pointer to an array".
  I admire your grasp of what is technically accurate and your ability
to quote from a draft ISO standard which you are assuming is infallible..

That is one point where Paul is right that most of us really call
"pointer to first element of array" as "pointer to array". We don't
use constructs like "int (*p2)[42] = 0;" enough to call them with some
special name. So these are "nothing" ... we simply don't call them ...
and therefore no conflicts arise.

There is a subtlety however. Note that the standard uses both the
term "pointer to /an/ array" and the term "pointer to array". Note
the difference of an "an". Furthermore, from some searching of the
draft it seems to only use the "an" form for the T * type (ie what
Paul wants to call "pointer to an array") and only uses the sans-
"an" form for the T (*)[...] type.

It makes some sense given that "an" connotes a particular /object/
and so directs one to think about the dynamic value of the pointer
and the object pointed to rather than the type of the pointer.

KHD
 
P

Paul

Leigh Johnston said:
Leigh Johnston said:
On 14/06/2011 08:19, gwowen wrote:
On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
(e-mail address removed)> wrote:
To be fair, it just occurred to me, as an example, that we do say
"pointer to
array of pointers" and not "pointer to first element in an array of
pointers".

I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).

I made it clear on multiple occasions that the phrases "pointer to"
and "points to" can mean different things *if* we are being less
formal (i.e. not technically accurate):
It is perfectly acceptable to say it's a "pointer to.." . and to mean
exactly the same as "it points to", because its very slight difference
is only grammatical.

If you want to say it's "type is pointer to.." then say that , it's
inaccurate to leave out the 'type' word and assume your definition of
the term "a pointer to" always can mean is "type pointer to" because
your interpretation is a sloppy interpretation and simply a shorthand
version of saying "it's type is pointer to".
int* p = new int[42];

1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.

(1) and (2) both describe the *type* of 'p' whilst (3) and (4)
describe runtime properties (i.e. the *objects* pointed to).

If we are being more formal (i.e. technically accurate) then I would
consider (4) to be incorrect.

This is a pointer to the right hand side of the page... ---->
It's "pointer to" the rhs of the page because it "points to" the rhs of
the page.
Both terms mean exactly the same thing but are used in a slightly
different grammatical context.

You are obviously very confused by the english language. Go away and try
to find some latin quotation so you can come back and disprove me.

My understanding of the English language informs me that "pointer" is a
noun and "points" is a verb. A noun is not "exactly the same thing" as a
verb; it is obvious to me who is having the problem with the English
language.
Congratulations, you understand the difference between a noun and a verb.

The expression "X is a pointer to Y's" is telling us what X can point to.
The expression "X points to Y's" is also telling us what X can point to.

Both terms tell us exactly the same thing, they are only different forms of
vocabulary
 
P

Paul

Leigh Johnston said:
To be fair, it just occurred to me, as an example, that we do say
"pointer to
array of pointers" and not "pointer to first element in an array of
pointers".

I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).

I made it clear on multiple occasions that the phrases "pointer to"
and "points to" can mean different things *if* we are being less
formal (i.e. not technically accurate):

It is perfectly acceptable to say it's a "pointer to.." . and to mean
exactly the same as "it points to", because its very slight difference
is only grammatical.

If you want to say it's "type is pointer to.." then say that , it's
inaccurate to leave out the 'type' word and assume your definition of
the term "a pointer to" always can mean is "type pointer to" because
your interpretation is a sloppy interpretation and simply a shorthand
version of saying "it's type is pointer to".

int* p = new int[42];

1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.

(1) and (2) both describe the *type* of 'p' whilst (3) and (4)
describe runtime properties (i.e. the *objects* pointed to).

If we are being more formal (i.e. technically accurate) then I would
consider (4) to be incorrect.


This is a pointer to the right hand side of the page... ---->
It's "pointer to" the rhs of the page because it "points to" the rhs of
the page.
Both terms mean exactly the same thing but are used in a slightly
different grammatical context.

You are obviously very confused by the english language. Go away and
try
to find some latin quotation so you can come back and disprove me.

My understanding of the English language informs me that "pointer" is
a noun and "points" is a verb. A noun is not "exactly the same thing"
as a verb; it is obvious to me who is having the problem with the
English language.
Congratulations, you understand the difference between a noun and a verb.

The expression "X is a pointer to Y's" is telling us what X can point to.
The expression "X points to Y's" is also telling us what X can point to.

Both terms tell us exactly the same thing, they are only different forms
of vocabulary

In C++ (or even in OO) the term "is a" or "is-a" is generally referring to
*types* so when we say "X is a pointer to int" we are describing the type
of 'X' not the type of the object 'X' happens to be pointing to (or into)
at runtime.

If you want to refer to the type then say "X is of type, pointer to Y".

Pointers don't point to types they point to objects, or memory locations
that contain data. A pointer of type int* can point to integer objects, or
nothing at all.

int* p1 = new int;
int* p2 = new int[22];
int* p3=0;

p1 points to a single integer, p2 points to an array of integers and p3
points to nothing at all.
 
P

Paul

Leigh Johnston said:
Leigh Johnston said:
To be fair, it just occurred to me, as an example, that we do say
"pointer to
array of pointers" and not "pointer to first element in an array
of
pointers".

I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).

I made it clear on multiple occasions that the phrases "pointer to"
and "points to" can mean different things *if* we are being less
formal (i.e. not technically accurate):

It is perfectly acceptable to say it's a "pointer to.." . and to mean
exactly the same as "it points to", because its very slight
difference
is only grammatical.

If you want to say it's "type is pointer to.." then say that , it's
inaccurate to leave out the 'type' word and assume your definition of
the term "a pointer to" always can mean is "type pointer to" because
your interpretation is a sloppy interpretation and simply a shorthand
version of saying "it's type is pointer to".

int* p = new int[42];

1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.

(1) and (2) both describe the *type* of 'p' whilst (3) and (4)
describe runtime properties (i.e. the *objects* pointed to).

If we are being more formal (i.e. technically accurate) then I would
consider (4) to be incorrect.


This is a pointer to the right hand side of the page... ---->
It's "pointer to" the rhs of the page because it "points to" the
rhs of
the page.
Both terms mean exactly the same thing but are used in a slightly
different grammatical context.

You are obviously very confused by the english language. Go away
and try
to find some latin quotation so you can come back and disprove me.

My understanding of the English language informs me that "pointer" is
a noun and "points" is a verb. A noun is not "exactly the same thing"
as a verb; it is obvious to me who is having the problem with the
English language.

Congratulations, you understand the difference between a noun and a
verb.

The expression "X is a pointer to Y's" is telling us what X can point
to.
The expression "X points to Y's" is also telling us what X can point
to.

Both terms tell us exactly the same thing, they are only different
forms
of vocabulary

In C++ (or even in OO) the term "is a" or "is-a" is generally
referring to *types* so when we say "X is a pointer to int" we are
describing the type of 'X' not the type of the object 'X' happens to
be pointing to (or into) at runtime.

If you want to refer to the type then say "X is of type, pointer to Y".

Pointers don't point to types they point to objects, or memory locations
that contain data. A pointer of type int* can point to integer objects,
or nothing at all.

int* p1 = new int;
int* p2 = new int[22];
int* p3=0;

p1 points to a single integer, p2 points to an array of integers and p3
points to nothing at all.

p2 points to the first element of an array of integers; crucially what do
we say p2 points to if we do:

++p2;

Continuing to say that p2 points to an array when it doesn't point to the
first element of an array is confusing at best.

No p2 points to an array of integer objects.

I've told you before you can point to a banana in a bunch yet you also point
to the bunch of bananas at the same time.
 
P

Paul

io_x said:
pointers point to memory, in memory can be object or not

That is more or less what I wrote but having reviewed the holy standard it
states:
"A pointer to objects of type T is referred to as a "pointer to T.""

So I guess a pointer can point to a type in a sense that it can point to an
object of type X.
However I don't think this is the generally accepted defintion of what a
pointer points-to, I stick to my original view that a pointer points to
memory locations, or objects stored there, which you seem to agree with.
that contain data. A pointer of type int* can point to integer objects,
or
nothing at all.

int* p1 = new int;
int* p2 = new int[22];
int* p3=0;

p1 points to a single integer, p2 points to an array of integers and p3
points
to nothing at all.

p3 point to address 0 in the memory

I think this value is used to represent a null pointer because it is not a
valid addressable address. I agree that in some contexts the pointer can be
seen to point to the address 0 but remember that a pointers' value is not
always a real address and it may be added to a base pointer where the result
would not be address 0 in memory.

Note: 0 may be a valid address on some system. IDK.
 
P

Paul

Leigh Johnston said:
Leigh Johnston said:
On 16/06/2011 20:06, Paul wrote:

To be fair, it just occurred to me, as an example, that we do
say
"pointer to
array of pointers" and not "pointer to first element in an
array of
pointers".

I don't know if anyone's ever suggested that's not a useful
colloquialism (well, Leigh maybe, but I wouldn't know).

I made it clear on multiple occasions that the phrases "pointer
to"
and "points to" can mean different things *if* we are being less
formal (i.e. not technically accurate):

It is perfectly acceptable to say it's a "pointer to.." . and to
mean
exactly the same as "it points to", because its very slight
difference
is only grammatical.

If you want to say it's "type is pointer to.." then say that , it's
inaccurate to leave out the 'type' word and assume your
definition of
the term "a pointer to" always can mean is "type pointer to"
because
your interpretation is a sloppy interpretation and simply a
shorthand
version of saying "it's type is pointer to".

int* p = new int[42];

1) 'p' is a pointer to an 'int';
2) 'p' is not a pointer to an array of 'int';
3) 'p' points to the first element of an array of 'int'
4) 'p' points to an array of 'int'.

(1) and (2) both describe the *type* of 'p' whilst (3) and (4)
describe runtime properties (i.e. the *objects* pointed to).

If we are being more formal (i.e. technically accurate) then I
would
consider (4) to be incorrect.


This is a pointer to the right hand side of the page... ---->
It's "pointer to" the rhs of the page because it "points to" the
rhs of
the page.
Both terms mean exactly the same thing but are used in a slightly
different grammatical context.

You are obviously very confused by the english language. Go away
and try
to find some latin quotation so you can come back and disprove me.

My understanding of the English language informs me that "pointer"
is
a noun and "points" is a verb. A noun is not "exactly the same
thing"
as a verb; it is obvious to me who is having the problem with the
English language.

Congratulations, you understand the difference between a noun and a
verb.

The expression "X is a pointer to Y's" is telling us what X can point
to.
The expression "X points to Y's" is also telling us what X can
point to.

Both terms tell us exactly the same thing, they are only different
forms
of vocabulary

In C++ (or even in OO) the term "is a" or "is-a" is generally
referring to *types* so when we say "X is a pointer to int" we are
describing the type of 'X' not the type of the object 'X' happens to
be pointing to (or into) at runtime.


If you want to refer to the type then say "X is of type, pointer to Y".

Pointers don't point to types they point to objects, or memory
locations
that contain data. A pointer of type int* can point to integer objects,
or nothing at all.

int* p1 = new int;
int* p2 = new int[22];
int* p3=0;

p1 points to a single integer, p2 points to an array of integers and p3
points to nothing at all.

p2 points to the first element of an array of integers; crucially what
do we say p2 points to if we do:

++p2;

Continuing to say that p2 points to an array when it doesn't point to
the first element of an array is confusing at best.

No p2 points to an array of integer objects.

I've told you before you can point to a banana in a bunch yet you also
point to the bunch of bananas at the same time.

You have told all of us your crazy analogies before; crazy analogies that
remain crazy no matter how many times you repeat them or vary them.

Pointing to a banana is not the same as pointing to a bunch of bananas.
It is if the pointed-to banana is part of a bunch. You cannot point to an
individual banana in a bunch without also pointing at the bunch of bananas.
'p2' is a pointer to a single 'int' not an array of 'int's.
The pointer is pointing to 22 objects of type int. Not one single object.
 
P

Paul

Leigh Johnston said:
If you want to refer to the type then say "X is of type, pointer to
Y".

Pointers don't point to types they point to objects, or memory
locations
that contain data. A pointer of type int* can point to integer
objects,
or nothing at all.

int* p1 = new int;
int* p2 = new int[22];
int* p3=0;

p1 points to a single integer, p2 points to an array of integers
and p3
points to nothing at all.

p2 points to the first element of an array of integers; crucially what
do we say p2 points to if we do:

++p2;

Continuing to say that p2 points to an array when it doesn't point to
the first element of an array is confusing at best.


No p2 points to an array of integer objects.

I've told you before you can point to a banana in a bunch yet you also
point to the bunch of bananas at the same time.

You have told all of us your crazy analogies before; crazy analogies
that remain crazy no matter how many times you repeat them or vary them.

Pointing to a banana is not the same as pointing to a bunch of bananas.
It is if the pointed-to banana is part of a bunch. You cannot point to
an individual banana in a bunch without also pointing at the bunch of
bananas.

No; if you are pointing to a bunch of bananas you are not pointing to an
individual banana. Your analogies are nonsense and/or pointless.
Yes you are pointing to the bunch yet ALSO a single banana at the same time
No it isn't, p2 is pointing to the first element of an array of 22 objects
of type 'int'.
Well it points to 22 int objects then.
If I do ...
++p2 , it still points to 22 int objects but it no longer points to the
first element.
I expect you to repeat yourself yet again by contradicting the facts yet
again, *yawn*.
You are the one who disagrees with the majority of the world about it.
 
P

Paul

Leigh Johnston said:
Leigh Johnston said:
On 17/06/2011 18:41, Paul wrote:
If you want to refer to the type then say "X is of type, pointer to
Y".

Pointers don't point to types they point to objects, or memory
locations
that contain data. A pointer of type int* can point to integer
objects,
or nothing at all.

int* p1 = new int;
int* p2 = new int[22];
int* p3=0;

p1 points to a single integer, p2 points to an array of integers
and p3
points to nothing at all.

p2 points to the first element of an array of integers; crucially
what
do we say p2 points to if we do:

++p2;

Continuing to say that p2 points to an array when it doesn't point
to
the first element of an array is confusing at best.


No p2 points to an array of integer objects.

I've told you before you can point to a banana in a bunch yet you
also
point to the bunch of bananas at the same time.

You have told all of us your crazy analogies before; crazy analogies
that remain crazy no matter how many times you repeat them or vary
them.

Pointing to a banana is not the same as pointing to a bunch of
bananas.
It is if the pointed-to banana is part of a bunch. You cannot point to
an individual banana in a bunch without also pointing at the bunch of
bananas.

No; if you are pointing to a bunch of bananas you are not pointing to
an individual banana. Your analogies are nonsense and/or pointless.
Yes you are pointing to the bunch yet ALSO a single banana at the same
time

No you are not.
Well it points to 22 int objects then.

It does not and can not. The type of an array of 22 objects of type 'int'
is unrelated to the type 'int' and related types are important when
discussing pointers and what can be assigned to them. The C++ standard
informs of what the pointer returned from new[] is:
An array of 22 int's is not unrelated to the int type.
"If it is an array, the new-expression returns a pointer to the initial
element of the array."

It does not return a pointer to an array.

Yes it does, the first element of an array is not a single element it is
...the first element,.... drumroll.... of an array.
Paul's fantasy world I am happy to disagree with.
Whatever.
 
K

Keith H Duggar

Leigh Johnston said:
On 16/06/2011 20:06, Paul wrote:
int* p1 = new int;
int* p2 = new int[22];
int* p3=0;
p1 points to a single integer, p2 points to an array of integers and p3
points to nothing at all.
p2 points to the first element of an array of integers; crucially what
do we say p2 points to if we do:
++p2;
Continuing to say that p2 points to an array when it doesn't point to
the first element of an array is confusing at best.
No p2 points to an array of integer objects.
I've told you before you can point to a banana in a bunch yet you also
point to the bunch of bananas at the same time.

You have told all of us your crazy analogies before; crazy analogies
that remain crazy no matter how many times you repeat them or vary them.

Pointing to a banana is not the same as pointing to a bunch of bananas.
'p2' is a pointer to a single 'int' not an array of 'int's.

According to the draft standard (and I think it is not likely to
change) p2 is a "pointer to /an/ array" though not a "pointer to
array". Likewise, ++p2 is also a "pointer to /an/ array" that so
happens to also be a sub-array.

So, unless the standard changes, your opinion directly conflicts
with it; you are wrong and Paul is consistent with the standard.

KHD
 
P

Paul

Leigh Johnston said:
On 16/06/2011 23:05, Paul wrote:
On 16/06/2011 20:06, Paul wrote:
int* p1 = new int;
int* p2 = new int[22];
int* p3=0;

p1 points to a single integer, p2 points to an array of integers and
p3
points to nothing at all.

p2 points to the first element of an array of integers; crucially what
do we say p2 points to if we do:

++p2;

Continuing to say that p2 points to an array when it doesn't point to
the first element of an array is confusing at best.

No p2 points to an array of integer objects.

I've told you before you can point to a banana in a bunch yet you also
point to the bunch of bananas at the same time.

You have told all of us your crazy analogies before; crazy analogies
that remain crazy no matter how many times you repeat them or vary them.

Pointing to a banana is not the same as pointing to a bunch of bananas.
'p2' is a pointer to a single 'int' not an array of 'int's.

According to the draft standard (and I think it is not likely to
change) p2 is a "pointer to /an/ array" though not a "pointer to
array". Likewise, ++p2 is also a "pointer to /an/ array" that so
happens to also be a sub-array.

So, unless the standard changes, your opinion directly conflicts
with it; you are wrong and Paul is consistent with the standard.

And according to the draft C standard the term "pointer to an array" is
what the draft C++ standard refers to as a "pointer to array". I am of
the opinion that the draft C++ standard is in error changing the meaning
of "pointer to an array": try applying some common sense.

int *p = 0; // pointer to int, pointer to an int

No , this pointer points to nothing. It can be said it is of "type pointer
to int", which is often shortened to "pointer to int".
The context of this is not the same a what is pointed-to, this context is
referring to the pointers type, or what the pointer is.

int (*pa) = 0; // pointer to array, pointer to an array

Again this pointer points to nothing.
You are confusing the term "is a pointer to ..whatever", with the context of
what is pointed-to and what type the pointer is.

As these two standards disagree on terminology I would say that you are
being premature saying that we are incorrect and that you two trolls who
happen to agree with each other are correct.

int* p=0;
This pointer can be said to be "a pointer to int" because that is its type.
It can also be said that this is "a pointer to nothing" because it points to
nothing.

One is neither correct or incorrect, each has a different context.
You seem to think that because the standard uses a particular context the
other context will be incorrect, but this is not the case.
Just as it's not the case that because a pointer points to the first element
of an array it does not also point to the array.

Both are correct, they are just used in different contexts. For example if
you pass an array to a function , you pass a pointer to the array. That
pointer references the array , as a whole, not just one single element. If
you dereference the pointer you access only one element.
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top