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?

1
  • 1
    Quick fix: double all of the curly braces. Commented Feb 21, 2019 at 19:35

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.