1

I'm running into an error when trying to declare and initialize a 2d array using the std::array class. I'm using syntax as described per an assignment, yet I'm running into issues. My code is the following:

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 }
};

I know the array is being declared correctly because if I don't initialize the values, and then I use syntax like grades[0][0] = 87 and grades[0][1] = 96, everything works smoothly without an error.

A couple of notes: I realize that I can use int grade[10][3] syntax, but that isn't permitted in this specific case.

Any ideas?

basodre
  • 5,720
  • 1
  • 15
  • 23

0 Answers0