RE: [Dev-C++] #DEFINE versus cont variables in array inicializations
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@te...> - 2003-05-29 16:12:20
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of Andr? Macario Barros > Sent: Thursday, May 29, 2003 4:09 PM > To: Dev-Cpp-Users > Subject: [Dev-C++] #DEFINE versus cont variables in array=20 > inicializations >=20 >=20 > Dear Users, >=20 > For the sake of flexibility, I think we only have two ways=20 > to iniciatize > a > size of an array: > 1) via #define: > #define MAX 10 > ... > int vect[MAX]; > ... >=20 > 2) via cont variable: > const int size=3D10; > ... > int vetc[size]; > ... The second in C++ only. So please all, explain what programming language = you are referring to, so as to avoid confusions. >=20 > So, in both ways, everytime if I need to change the size of=20 > the arrays, it=B4s The *initial* size of built in arrays... > only necessary to change 10 to the other value. >=20 > -->My questions: > 1) Is there more ways to to this? For built in arrays, no (except of int vetc[10]; of course). > 2) For theese two ways presented here, when use one and when=20 > use the other? Use the second. The first is used in C because the second is not = availlable. Also keep in mind that C and C++ are very different languages now. > Explaining a little more what I need to know: in a "good=20 > programming > technique" > point of view, what of theese two is the preferred of the=20 > programmers The second. But standard library containers should be preferred more. Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |