Re: 2 dimensional arrays
From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: 08/31/04
- Next message: Francis Glassborow: "Re: Is export "useless and broken"?"
- Previous message: Ioannis Vranos: "Re: How to expand my compiler's ULONG_MAX ?"
- In reply to: Ivan Korotkov: "Re: 2 dimensional arrays"
- Next in thread: kanze_at_gabi-soft.fr: "Re: 2 dimensional arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Aug 2004 08:08:31 -0400 To: (Usenet)
In article <opsdind2n6win0yh@news.zebratelecom.ru>, Ivan Korotkov
<clcppm-poster@this.is.invalid> writes
>Or better this:
>
>int (*pi)[3] = new int[2][3];
>
>The former method loses in performance (because each array access needs
>two derefernces). The latter one doesn't, it's just the same as { int
>pi[2][3]; }
I'd prefer to see '3' replaced. Either by:
int const row_length(3);
or:
typedef int row[3];
row * array(new row[2]);
Or even better, do both:
int const row_length(3);
typedef int row[row_length];
int const rows(2);
row * array(new row[rows]);
typedefs are a good way to handle 'magic' types.
-- Francis Glassborow ACCU Author of 'You Can Do It!' see http://www.spellen.org/youcandoit For project ideas and contributions: http://www.spellen.org/youcandoit/projects [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
- Next message: Francis Glassborow: "Re: Is export "useless and broken"?"
- Previous message: Ioannis Vranos: "Re: How to expand my compiler's ULONG_MAX ?"
- In reply to: Ivan Korotkov: "Re: 2 dimensional arrays"
- Next in thread: kanze_at_gabi-soft.fr: "Re: 2 dimensional arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]