I have a class Thing
sporting no default constructor.
Now we define another class, which now has to initalise the array elements at once, as without a default constructor, no late assignment can be made. So we have:
class TwoThings
{
public:
Thing things[2];
TwoThings() : things({Thing("thing 1"),Thing("thing 2")})
{
}
}
Is this the correct way?
GCC compiles it fine, while Clang does not, stating an "initializer list" should be used. I tried several alternative ways like double braces {{ ... }}
and such, but can't manage to get a compiling equivalent for Clang.
How to initialise arrays without default constructor in Clang?