c ++中的数组有很多错误

时间:2019-03-09 01:00:17

标签: c++ c++11

所以我的以下代码行有很多错误,但是我似乎找不到解决方法。显示的错误表明初始化程序太多,必须使用大括号括起的初始化程序来初始化数组。谁能帮忙吗?

const std::array<std::array<int, 3>, 8> m_rows =
    {{
        {0,3,6},
        {1,4,7},
        {2,5,8},
        {0,1,2},
        {3,4,5},
        {6,7,8},
        {0,4,8},
        {2,4,6}
    }};

1 个答案:

答案 0 :(得分:2)

您可能需要额外的{}

const std::array<std::array<int, 3>, 8> m_rows =
{{
    {{0,3,6}},
    {{1,4,7}},
    {{2,5,8}},
    {{0,1,2}},
    {{3,4,5}},
    {{6,7,8}},
    {{0,4,8}},
    {{2,4,6}}
}};