www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/11/29/14:03:14

Xref: news-dnh.mv.net comp.lang.c++:59013 comp.os.msdos.djgpp:3475
Path: news-dnh.mv.net!mv!news.sprintlink.net!hookup!news.mathworks.com!news.kei.com!nntp.coast.net!oleane!in2p3.fr!swidir.switch.ch!scsing.switch.ch!news.belwue.de!news.uni-konstanz.de!uzwil!kuehl
From: kuehl AT uzwil DOT sun DOT soe DOT clarkson DOT edu (Dietmar Kuehl)
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Subject: Re: Declaring arrays inside generic function
Date: 29 Nov 1995 00:44:51 GMT
Organization: Fakultät für Mathematik und Informatik
Lines: 27
Distribution: world
References: <Pine DOT A32 DOT 3 DOT 91 DOT 951127202934 DOT 29743A-100000 AT srv1 DOT freenet DOT calgary DOT ab DOT ca>
Reply-To: dietmar DOT kuehl AT uni-konstanz DOT de
Nntp-Posting-Host: uzwil.informatik.uni-konstanz.de
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,
"Michael E. Wesolowski" (mewesolo AT freenet DOT calgary DOT ab DOT ca) wrote:
: I have a generic function which has as one of its input parameters an int 
: which identifies an array size. Within the function, I attempt to declare 
: an array of int's:
: 
: int item_count [array_size];

Dynamically determining the size of an array allocated on the stack is
a gcc extension. If you need a dynamic array, you should use 'vector'
instead of a built-in array. Actually, you should not use built-in
array any where else than in some classes to implement them (this is
not a language requirement but results from the style built-in arrays
are dealt with by the language).

: If it's something in the ANSI standard, I'd appreciate the paragraph 
: reference as well as a simple description of what's going on. Thanks.

dcl.array verse 1: there is explicitly stated that the expression used
to determine the size of an array has to be const. You can also have a
look at a current discussion in comp.std.c++ concerning dynamic array
bounds (for built-in arrays). The thread is titled "Array
Initialization".
--
dietmar DOT kuehl AT uni-konstanz DOT de
http://www.informatik.uni-konstanz.de/~kuehl
I am a realistic optimist - that's why I appear to be slightly pessimistic

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019