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?
Overload Journal #42 - Apr 2001 + Programming Topics + Letters to the Editor
|Browse in :||
All > Topics > Programming (768)
All > Journal Columns > LettersEditor (127)
Any of these categories - All of these categories