Programming Topics + Letters to the Editor + Overload Journal #42 - Apr 2001
Browse in : All > Topics > Programming
All > Journal Columns > LettersEditor
All > Journals > Overload > 42
Any of these categories - All of these categories

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: Editor << letters;

Author: Administrator

Date: 26 April 2001 17:46:06 +01:00 or Thu, 26 April 2001 17:46:06 +01:00

Summary: 

Body: 

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?

Notes: 

More fields may be available via dynamicdata ..