frankzappa
Well-known member
Hello!
I'm learning C++ and I've just started the chapter on OOP, classes, constructors etc. There is something called "member initialisation list" where you can use direct or uniform initialisation to initialise an object with constexpr members. Constexpr variables are tricky because you can't assign a value to them, you can only initialise them so you have to use an initialisation list as far as I understand.
My question is, does this work in the Arduino IDE? I can't seem to get it to work. In fact uniform initialisation doesn't seem to work. Is there a different syntax for this in arduino? I can use for example int x = {0}; but int x{0}; doesn't seem to work.
Also It seems you can zero initialise an array without using a for loop but again I haven't been able to do it in arduino.
Is there any difference between the three types of initialisation?
I'm learning C++ and I've just started the chapter on OOP, classes, constructors etc. There is something called "member initialisation list" where you can use direct or uniform initialisation to initialise an object with constexpr members. Constexpr variables are tricky because you can't assign a value to them, you can only initialise them so you have to use an initialisation list as far as I understand.
My question is, does this work in the Arduino IDE? I can't seem to get it to work. In fact uniform initialisation doesn't seem to work. Is there a different syntax for this in arduino? I can use for example int x = {0}; but int x{0}; doesn't seem to work.
Also It seems you can zero initialise an array without using a for loop but again I haven't been able to do it in arduino.
Is there any difference between the three types of initialisation?