Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #14485
| From | "Paul" <pchrist<nospam>or@yahoo.co.uk> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Pointer Problem |
| Date | 2012-02-24 15:49 +0000 |
| Organization | Netfront http://www.netfront.net/ |
| Message-ID | <ji8bjd$e2m$1@adenine.netfront.net> (permalink) |
| References | (8 earlier) <slrnjkd9pi.1ls.grahn+nntp@frailea.sa.invalid> <e365083e-3c7e-471f-8999-fe1024161199@gi10g2000vbb.googlegroups.com> <SbednbLbF-_RGdrSnZ2dnUVZ8kCdnZ2d@giganews.com> <1a33612f-5c15-41b6-80e2-5efc589ce966@s7g2000vby.googlegroups.com> <upidnQHsXYY4B9rSnZ2dnUVZ8qOdnZ2d@giganews.com> |
"Leigh Johnston" <leigh@i42.co.uk> wrote in message
news:upidnQHsXYY4B9rSnZ2dnUVZ8qOdnZ2d@giganews.com...
> On 24/02/2012 14:07, Paul wrote:
>> On Feb 24, 12:36 pm, Leigh Johnston<le...@i42.co.uk> wrote:
>>> On 24/02/2012 12:11, Paul wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> On Feb 23, 8:53 pm, Jorgen Grahn<grahn+n...@snipabacken.se> wrote:
>>>>> On Wed, 2012-02-22, Paul wrote:
>>>
>>>>> ...
>>>
>>>>>> What you're saying is like saying int* and int** point to different
>>>>>> types. Sure if you assert them at different levels of indirection
>>>>>> they
>>>>>> will appear different but regarding types, ultimately they both point
>>>>>> to an int type object.
>>>
>>>>>> If your argument would be to suggest that they point to different
>>>>>> types because int** points to an int* type and int* points to an int
>>>>>> type. I'd suggest that you are confusing the term "level of
>>>>>> indirection" with "type".
>>>
>>>>> You may not like it, but that's the accepted terminology in C++.
>>>
>>>> AFAICT the accepted terminology in C++ is that a pointer of type T*
>>>> can point to a T or an array of T's.
>>>
>>>>> You have some kind of point of course: the only reason to mess around
>>>>> with int*, int** or int***** is to eventually do something to a bunch
>>>>> of ints. But the language doesn't know, or care.
>>>
>>>> I was merely trying to demonstrate that different levels of
>>>> indirection do not change the object type. The object pointed to is an
>>>> int type, whether you create a pointer to it with one level of
>>>> indirection or five i.e: int*****.
>>>> The same applies to an array, the arrays' type does not change because
>>>> of the pointer type used to address it. An array of chars, for
>>>> example, is addressed using a char* because you cannot address n x
>>>> chars, you can address only one char. If you create a pointer with two
>>>> or three levels of indirection to this array of chars it doesn't
>>>> change the type of the pointed-to object.
>>>
>>>> And this is exactly what a pointer of type char(*ptr)[S] is, a pointer
>>>> to chars with two levels of indirection. The level of indirection
>>>> doesn't affect the type of the addressed object.
>>>
>>>> Yeah sure you can be really pedantic and argue that between each level
>>>> of indirection the pointer type changes from eg: char*** to char** to
>>>> char*. But at the end of the day each of these pointers is just
>>>> another pointer variable that stores a memory address and its doesn't
>>>> really change the type of the pointed-to object. Its just changing in
>>>> levels of indirection. For example: a char**** is a pointer to a char
>>>> just the same as a char** is a pointer to a char, is it not?.
>>>
>>> No; char**** is a pointer to a char***.
>>>
>> You're reply is incorrect on two points:
>> a) The pointer may point to a char indirectly.
>> b) The pointer may be null and point to nothing.
>>
>> The scenario , that you agree with, where char**** is a pointer to a
>> char*** you are considering only one level of indirection:
>> char**** ---- dereferneces to ---> char***.
>>
>> Now considering a less simpleton mind:
>> char**** ---> char*** ---> char** ---> char* ---> char.
>>
>>
>> It may point to a char(indirectly) *and* a char***. You'd be incorrect
>> to say this is incorrect.
>>
>>
>>
>>
>>
>> Just as with the pointer type int(*)[S]. You say that this is a
>> pointer to an array of S, and only to an array of S, all other
>> contexts are deemed as incorrect. But this is nonsense because:
>>
>> int array1[8][10] = {0};
>> int array2[9][10] ={0};
>> int array3[10]={0};
>> int (*ptr1)[10];
>> ptr1 = array1;
>> ptr1 = array2;
>> ptr1 =&array3;
>>
>>
>> It is correct to say that ptr1 points to 3 different sized arrays and
>> incorrect to say that ptr1 is only a pointer to an array of 10 ints.
>> The pointer type can point to arrays of different sizes and not only
>> to an array of 10 ints. The difference between this pointer type and
>> an int* type is obviously in it's level of indirection. The int type
>> never changes from each level of indirection, only the pointer-type to
>> reflect that different level of indirection, as in the case with
>> char***, char**, char*.
>
> You are so wrong that you could say that you are not *even* wrong.
>
You don't make alot of sense.
--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Pointer Problem bintom <binoythomas1108@gmail.com> - 2012-02-16 06:51 -0800
Re: Pointer Problem Juha Nieminen <nospam@thanks.invalid> - 2012-02-16 15:15 +0000
Re: Pointer Problem 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-16 07:17 -0800
Re: Pointer Problem Victor Bazarov <v.bazarov@comcast.invalid> - 2012-02-16 11:15 -0500
Re: Pointer Problem scott@slp53.sl.home (Scott Lurndal) - 2012-02-16 17:18 +0000
Re: Pointer Problem Victor Bazarov <v.bazarov@comcast.invalid> - 2012-02-16 13:46 -0500
Re: Pointer Problem Mike McCarty <mcmccarty@gmail.com> - 2012-02-16 12:41 -0800
Re: Pointer Problem scott@slp53.sl.home (Scott Lurndal) - 2012-02-16 20:45 +0000
Re: Pointer Problem Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-17 01:44 -0800
Re: Pointer Problem jt@toerring.de (Jens Thoms Toerring) - 2012-02-17 03:14 +0000
Re: Pointer Problem Juha Nieminen <nospam@thanks.invalid> - 2012-02-17 07:23 +0000
Re: Pointer Problem jt@toerring.de (Jens Thoms Toerring) - 2012-02-18 22:39 +0000
Re: Pointer Problem Peter Remmers <p.remmers@expires-2011-04-30.arcornews.de> - 2012-02-20 21:07 +0100
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-21 18:49 -0800
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-21 18:49 -0800
Re: Pointer Problem Juha Nieminen <nospam@thanks.invalid> - 2012-02-22 10:15 +0000
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-22 07:49 -0800
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-22 20:24 +0000
Re: Pointer Problem Juha Nieminen <nospam@thanks.invalid> - 2012-02-23 10:36 +0000
Re: Pointer Problem "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-02-23 18:59 +0000
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-23 19:15 +0000
Re: Pointer Problem "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-02-23 21:08 +0000
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-23 21:17 +0000
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-23 21:29 +0000
Re: Pointer Problem Joshua Maurice <joshuamaurice@gmail.com> - 2012-02-23 17:06 -0800
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-24 03:42 -0800
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-24 12:33 +0000
Re: Pointer Problem "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-02-24 15:09 +0000
Re: Pointer Problem Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-02-23 20:53 +0000
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-24 04:11 -0800
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-24 12:36 +0000
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-24 06:07 -0800
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-24 14:11 +0000
Re: Pointer Problem "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-02-24 15:49 +0000
Re: Pointer Problem Mike McCarty <mcmccarty@gmail.com> - 2012-02-24 08:50 -0800
Re: Pointer Problem "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-02-24 18:47 +0000
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-24 13:44 -0800
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-26 12:41 -0800
Re: Pointer Problem Mike McCarty <mcmccarty@gmail.com> - 2012-02-26 21:30 -0800
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-27 06:07 -0800
Re: Pointer Problem Mike McCarty <mcmccarty@gmail.com> - 2012-02-27 07:25 -0800
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-27 08:17 -0800
Re: Pointer Problem Mike McCarty <mcmccarty@gmail.com> - 2012-02-27 08:51 -0800
Re: Pointer Problem Ian Collins <ian-news@hotmail.com> - 2012-02-28 07:18 +1300
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-27 11:32 -0800
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-27 11:32 -0800
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-27 19:17 +0000
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-27 11:49 -0800
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-27 20:04 +0000
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-27 12:55 -0800
Re: Pointer Problem Leigh Johnston <leigh@i42.co.uk> - 2012-02-27 21:15 +0000
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-27 14:26 -0800
Re: Pointer Problem Paul <pchristor@yahoo.co.uk> - 2012-02-27 11:21 -0800
Re: Pointer Problem SG <s.gesemann@gmail.com> - 2012-02-16 07:00 -0800
Re: Pointer Problem LR <lruss@superlink.net> - 2012-02-16 16:49 -0500
Re: Pointer Problem Juha Nieminen <nospam@thanks.invalid> - 2012-02-16 22:18 +0000
Re: Pointer Problem LR <lruss@superlink.net> - 2012-02-16 23:40 -0500
Re: Pointer Problem Juha Nieminen <nospam@thanks.invalid> - 2012-02-17 07:24 +0000
Re: Pointer Problem LR <lruss@superlink.net> - 2012-02-17 09:48 -0500
Re: Pointer Problem Juha Nieminen <nospam@thanks.invalid> - 2012-02-17 15:13 +0000
csiph-web