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


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

Re: What is a `**ppEnum`?

From Juha Nieminen <nospam@thanks.invalid>
Newsgroups comp.lang.c++
Subject Re: What is a `**ppEnum`?
Date 2022-11-17 08:25 +0000
Organization Aioe.org NNTP Server
Message-ID <tl4r60$1026$1@gioia.aioe.org> (permalink)
References (2 earlier) <tkt2u9$1no3l$2@dont-email.me> <ff8b48f4-e2f9-4ae9-865d-7e657f4ac1c0n@googlegroups.com> <tkt73c$1o60i$2@dont-email.me> <tl2bj1$1en4$1@gioia.aioe.org> <tl3t9g$2f98u$1@dont-email.me>

Show all headers | View raw


T <T@invalid.invalid> wrote:
> The only thing I am not following, is how do I know the
> length of each item in the array and how many items are
> in the array.

The size (in bytes, if that's what you mean) of each element in the
array is just the sizeof the element type. If you have a 'Type*' pointer,
then the size of each element in the array is sizeof(Type).

A pointer does not carry with itself any information about what it's
pointing to (other than the type of that thing). In other words, you
cannot know, from the pointer alone, whether it's pointing to a single
value or to an array, or what the size of that array is.

So to answer your question about how you know how many items there are
in the array: You don't.

You need to pass the number of elements in the array as a separate value
alongside the pointer.

(To make this easier you could eg. create a struct that has the pointer
and a 'std::size_t' member variable telling how many elements there
are in the array pointed to by the pointer.)

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