Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++';初始值设定项值过多';使用数组类_C++ - Fatal编程技术网

C++ C++';初始值设定项值过多';使用数组类

C++ C++';初始值设定项值过多';使用数组类,c++,C++,尝试使用std::array类声明和初始化2d数组时遇到错误。我在使用作业中描述的语法,但我遇到了一些问题。我的代码如下: array<array<int, 3>, 10> grades { { 87, 96, 70 }, { 68, 87, 90 }, { 94, 100, 90 }, { 100, 81, 82 }, { 83, 65, 85 }, { 78 ,87, 65 }, { 85, 75, 83 },

尝试使用
std::array
类声明和初始化2d数组时遇到错误。我在使用作业中描述的语法,但我遇到了一些问题。我的代码如下:

array<array<int, 3>, 10> grades
{
    { 87, 96, 70 },
    { 68, 87, 90 },
    { 94, 100, 90 },
    { 100, 81, 82 },
    { 83, 65, 85 },
    { 78 ,87, 65 },
    { 85, 75, 83 },
    { 91, 94, 100 },
    { 76, 72, 84 },
    { 87, 93, 73 }
};
数组等级
{
{ 87, 96, 70 },
{ 68, 87, 90 },
{ 94, 100, 90 },
{ 100, 81, 82 },
{ 83, 65, 85 },
{ 78 ,87, 65 },
{ 85, 75, 83 },
{ 91, 94, 100 },
{ 76, 72, 84 },
{ 87, 93, 73 }
};
我知道数组的声明是正确的,因为如果我不初始化值,然后使用
grades[0][0]=87
grades[0][1]=96等语法,那么一切都会顺利进行,不会出错

注意:我意识到我可以使用
intgrade[10][3]
语法,但在这种特殊情况下是不允许的


有什么想法吗?

快速修复:将所有花括号加倍。快速修复:将所有花括号加倍。