Editor << letters;

Editor << letters;

By Dave Midgly

Overload, 9(42):, April 2001

It's not often I feel like I've fallen down a hole in the language definition, but this one puzzled me so I thought I'd throw it at the Overload readership.

I have a class X with no default constructor (maybe I don't even have the source), and I want to declare an array of Xs as a member of class Y. How do I do it? With no default constructor the Xs must be initialised in the constructor initialiser list of Y:Y(), but there doesn't seem to be a way of initialising an array (any sort of array, in fact, even of a base type) in a constructor initialiser list. I've searched The ARM and several other books, and I can't find anyone who specifically says that you can't do it, but also no one who says you can.

Logically I would expect to be able to do this, I can see no reason why the language shouldn't allow it, or, if there were a reason, I would expect the ARM to specifically mention why it is excluded. (Obviously there are get-around - e.g. declare an array of pointers and dynamically create new objects).

Did I miss something obvious?