My foo
class needs a static C++ array
as a private member that I eventually declared this way :
class Foo : public Bar {
private:
constexpr static array<int, 18> rouges = {1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36};
// ...
}
but the compiler throws
error: array must be initialized with a brace-enclosed initializer
error: too many initializers for 'const std::array<int, 18u>'
Funny thing my array size is exactly 18 elements here and if I declare it array<int, 500>
I still get the too many initializers
error. As for the brace-enclosed initializer error, I don't understand what the compiler expects to read.
I documented myself by looking into Stroustrup's A Tour of C++ (11.3.1 array
) but I don't see how he did it differently that I did. Alternatively, removing the constexpr static
keywords doesn't get rid of the errors.
Thanks for your insight.