This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Initialize C ++ object array in constructor?

I am facing issues with initialization of an object array within the Constructor. I would like to initialize my array using initialization from brace-enclosed lists. But the armcc compiler for some reason, doesn't compile my code nor throw me a warning!

For example, the array would be of "Component" type:

class Component
{
public:
    Component(const uint8_t componentValue);
private:
    const uint8_t ComponentValue;

};

Next, the "Device" class, would utilize the "Component" in an array.

class Device
{
public:
    Device();

private:
    Component components[3];
};

Now, within the Device.cpp, I try to initialize the array in the default constructor call as:

Device::Device()
    : components{Component(3),Component(4),Component(5)}
{}

I have set my compilation flags to -cpp11. Also, this code compiles on a "arm-none-eabi-g++" compiler.

Why am I not able to compile this on armcc 5.06?