Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #87412

Re: What is a `**ppEnum`?

From Juha Nieminen <nospam@thanks.invalid>
Newsgroups comp.lang.c++
Subject Re: What is a `**ppEnum`?
Date 2022-11-16 09:47 +0000
Organization Aioe.org NNTP Server
Message-ID <tl2bj1$1en4$1@gioia.aioe.org> (permalink)
References <tksuro$1nh25$1@dont-email.me> <cc3b22c7-20a3-403b-9e87-bdd6d75d46e1n@googlegroups.com> <tkt2u9$1no3l$2@dont-email.me> <ff8b48f4-e2f9-4ae9-865d-7e657f4ac1c0n@googlegroups.com> <tkt73c$1o60i$2@dont-email.me>

Show all headers | View raw


T <T@invalid.invalid> wrote:
> `*` is a C pointer
> 
> `**` is a C pointer that points to another
> C pointer  (AAAHHH!)

Since pointers in C (and thus C++) can point to a single value or an
entire array of values (well, technically speaking a single value
pretty much behaves like it were an array of size 1, so one could
think that pointers *always* point to an array, even if that "array"
is just one single non-array variable), it can become confusing
quite fast when mixing these two uses. Sometimes you may have a
pointer pointing to an array of pointers. Or sometimes you may have
a pointer pointing to another pointer (which in itself might be
pointing to a single value or an array of values).

One practical example of a double pointer is the second parameter to the
strtol() function. The reason why it takes a pointer-to-a-pointer is
because it needs to be able to modify the original pointer to point
somewhere else (ie. it needs to be able to assign a new value to that
original pointer variable).

(A better solution to this would have been to make strtol() return
a struct with two values: The evaluated integer and the new end pointer.
But this design was rarely if ever used in the early days of C. There
may also be some "you don't have to pay for what you don't use" design
in play here, because if you don't need the new end pointer you can
just pass NULL as the parameter.)

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-14 00:39 -0800
  Re: What is a `**ppEnum`? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-11-14 01:29 -0800
    Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-14 01:46 -0800
      Re: What is a `**ppEnum`? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-11-14 01:52 -0800
        Re: What is a `**ppEnum`? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-11-14 01:55 -0800
      Re: What is a `**ppEnum`? Öö Tiib <ootiib@hot.ee> - 2022-11-14 02:30 -0800
        Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-14 02:38 -0800
          Re: What is a `**ppEnum`? Öö Tiib <ootiib@hot.ee> - 2022-11-14 02:48 -0800
  Re: What is a `**ppEnum`? Öö Tiib <ootiib@hot.ee> - 2022-11-14 01:39 -0800
    Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-14 01:48 -0800
      Re: What is a `**ppEnum`? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-11-14 02:01 -0800
      Re: What is a `**ppEnum`? Öö Tiib <ootiib@hot.ee> - 2022-11-14 02:33 -0800
        Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-14 02:59 -0800
          Re: What is a `**ppEnum`? Öö Tiib <ootiib@hot.ee> - 2022-11-14 03:33 -0800
            Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-14 11:10 -0800
          Re: What is a `**ppEnum`? Juha Nieminen <nospam@thanks.invalid> - 2022-11-16 09:47 +0000
            Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-16 15:55 -0800
              Re: What is a `**ppEnum`? scott@slp53.sl.home (Scott Lurndal) - 2022-11-17 00:19 +0000
              Re: What is a `**ppEnum`? Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-11-17 01:21 +0000
                Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-16 18:01 -0800
                Re: What is a `**ppEnum`? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-11-16 18:40 -0800
                Re: What is a `**ppEnum`? Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-11-17 04:18 +0000
              Re: What is a `**ppEnum`? Juha Nieminen <nospam@thanks.invalid> - 2022-11-17 08:25 +0000
                Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-17 00:31 -0800
                Re: What is a `**ppEnum`? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-11-17 10:17 -0800
              Re: What is a `**ppEnum`? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-11-17 13:03 +0000
                Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-17 10:28 -0800
          Re: What is a `**ppEnum`? Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-11-17 03:36 +0000
            Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-16 20:57 -0800
  Re: What is a `**ppEnum`? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-11-14 14:34 +0100
    Re: What is a `**ppEnum`? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-11-14 14:44 +0100
    Re: What is a `**ppEnum`? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-11-14 09:12 -0800
    Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-14 11:02 -0800
      Re: What is a `**ppEnum`? Ralf Fassel <ralfixx@gmx.de> - 2022-11-15 10:17 +0100
        Re: What is a `**ppEnum`? Öö Tiib <ootiib@hot.ee> - 2022-11-15 04:24 -0800
      Re: What is a `**ppEnum`? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-11-15 14:04 +0100
        Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-15 08:28 -0800
          Re: What is a `**ppEnum`? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-11-17 16:21 +0100
            Re: What is a `**ppEnum`? T <T@invalid.invalid> - 2022-11-17 16:39 -0800
              Re: What is a `**ppEnum`? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-11-19 14:16 +0100

csiph-web