Topic: New feature


Author: Michiel Salters<Michiel.Salters@cmg.nl>
Date: Mon, 19 Mar 2001 16:46:22 GMT
Raw View
In article <3ab16529$1_2@news.nwlink.com>, ALL YOUR BASE ARE BELONG TO US
says...
>
>I'd like to suggest a new feature: "array element initializers".
>
>If you have a member variable which is an array,
>it would be nice to initialize specific elements in the
>array, as shown in the following code:
>
>class A
>{
>    A();
>    A(int);
>};
>
>class B
>{
>    A array[10];
>
>    // Initialize specific array elements
>    // Remaing elements naturally receive automatic initialization
>    B() : array[3]( 6 ), array[9]()
>    {
>    }
>
>};
>
>The array indices would have to be distinct sequences of constants
>limited to the array bounds. Otherwise you might end up initializing
>the same thing twice (e.g. if i == 0 then [1][2] and [i + 1][2 - i] would
>conflict.).

Considering that plain arrays are considered almost deprecated
for user code, I don't think there is much support for this now.

Besides, you didn't specify in which order this initialization
happens.

I also would like to see an example in which this extension leads
to a better program. I.e. show us an example using this, and show
us why these members shouldn't be initialized in the ctor body,
nor by any other means.

Regards,
Michiel Salters

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]