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


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

Re: best way to pass a multiple dimension variable to a method

Path csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c++
Subject Re: best way to pass a multiple dimension variable to a method
Date Thu, 22 Dec 2022 03:02:15 +0000
Organization A noiseless patient Spider
Lines 31
Message-ID <873598ta2w.fsf@bsb.me.uk> (permalink)
References <tnvqqq$1466q$1@dont-email.me> <to00no$14ojn$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
Injection-Info reader01.eternal-september.org; posting-host="d7d033ef05c573a0094d614fba2038d6"; logging-data="1344013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++Iqe05a+9++rBLXrqNnq0wtI26Fp7/LI="
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock sha1:bUdLbPE58horjiqyvxmanDVvJKw= sha1:tORrup0CZwS+1qioUh+lxr4Lt80=
X-BSB-Auth 1.730a214a824820e62716.20221222030215GMT.873598ta2w.fsf@bsb.me.uk
Xref csiph.com comp.lang.c++:88211

Show key headers only | View raw


Lynn McGuire <lynnmcguire5@gmail.com> writes:

> On 12/21/2022 2:37 PM, Lynn McGuire wrote:
>> What is the best way to pass a multiple dimension variable to a method in C++ ?
>> For instance, in C you could do the following:
>>      double xyz [5] [2] [14];
>>      ...
>>      amethod (xyz, ...);

Best is always going to depend on lost of as yet unspecified factors.
Are the sizes (other than the "top-level" one) always know at compile
time?  Are they always the same?

> I am looking at
>    https://www.educba.com/3d-arrays-in-c-plus-plus/

That hardly scratches the surface!

> and
>
> https://stackoverflow.com/questions/8767166/passing-a-2d-array-to-a-c-function

C has variably modified types which means you can pass run-time array
sizes to a C function.  C++ does not have this feature, but then that
page includes some C++ and does not use variably modified types (as far
as I could see).

You probably need to say more about your constraints to get better advice.

-- 
Ben.

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


Thread

best way to pass a multiple dimension variable to a method Lynn McGuire <lynnmcguire5@gmail.com> - 2022-12-21 14:37 -0600
  Re: best way to pass a multiple dimension variable to a method Richard Damon <Richard@Damon-Family.org> - 2022-12-21 17:10 -0500
  Re: best way to pass a multiple dimension variable to a method Lynn McGuire <lynnmcguire5@gmail.com> - 2022-12-21 16:18 -0600
    Re: best way to pass a multiple dimension variable to a method Öö Tiib <ootiib@hot.ee> - 2022-12-21 18:03 -0800
      Re: best way to pass a multiple dimension variable to a method David Brown <david.brown@hesbynett.no> - 2022-12-22 15:03 +0100
    Re: best way to pass a multiple dimension variable to a method Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-22 03:02 +0000
      Re: best way to pass a multiple dimension variable to a method Lynn McGuire <lynnmcguire5@gmail.com> - 2022-12-22 02:01 -0600
        Re: best way to pass a multiple dimension variable to a method Öö Tiib <ootiib@hot.ee> - 2022-12-22 00:25 -0800
        Re: best way to pass a multiple dimension variable to a method Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-22 12:13 +0000
  Re: best way to pass a multiple dimension variable to a method Paavo Helde <eesnimi@osa.pri.ee> - 2022-12-22 09:07 +0200
  Re: best way to pass a multiple dimension variable to a method Lynn McGuire <lynnmcguire5@gmail.com> - 2022-12-22 22:10 -0600
  Re: best way to pass a multiple dimension variable to a method Lynn McGuire <lynnmcguire5@gmail.com> - 2022-12-22 22:23 -0600

csiph-web