🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.djgpp
Article #3

Re: Declaring arrays inside generic function

#3
From: Dietmar Kuehl
Date: Wed, 29 Nov 1995 00:44
27 lines
1824 bytes
Hi,
"Michael E. Wesolowski" (mewesolo@freenet.calgary.ab.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.kuehl@uni-konstanz.de
http://www.informatik.uni-konstanz.de/~kuehl
I am a realistic optimist - that's why I appear to be slightly pessimistic
Technical Details
Message-ID: <49gae3$8vs@eurybia.rz.uni-konstanz.de>
Path: arc1-ca.pugleaf.net!news.uni-konstanz.de!uzwil!kuehl
References: <Pine.A32.3.91.951127202934.29743A-100000@srv1.freenet.calgary.ab.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.uni-konstanz.de!uzwil!kuehl
From: kuehl@uzwil (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
Distribution: world
Message-ID: <49gae3$8vs@eurybia.rz.uni-konstanz.de>
References: <Pine.A32.3.91.951127202934.29743A-100000@srv1.freenet.calgary.ab.ca>
Reply-To: dietmar.kuehl@uni-konstanz.de
NNTP-Posting-Host: uzwil.informatik.uni-konstanz.de
X-Newsreader: TIN [version 1.1 PL6]