I don’t know why I can’t initialize an array of an array in C++

I have this piece of code in C++:

std::array<std::array<int, 2>, 4> elements = {{1,2},{1,2},{1,2},{1,2}};

and it says: error: excess elements in struct initializer

I don’t know why that happens. If I write that it works:

std::array<std::array<int, 2>, 4> elements = {{1,2}};

Source: Windows Questions C++

LEAVE A COMMENT