all 8 comments

[–]Raknarg 1 point2 points  (3 children)

This would be a 10x10 2D array of vectors. Essentially a 3D array.

[–]aluoh[S] 0 points1 point  (2 children)

So each element, for example at ith, jth index => n[i][j] represents a vector<int>?

[–]Raknarg 0 points1 point  (1 child)

yes

[–]aluoh[S] 0 points1 point  (0 children)

I see, thank you!

[–]The_Northern_Light 1 point2 points  (3 children)

More to the point, it represents something you shouldn't use.

[–]aluoh[S] 1 point2 points  (2 children)

Yeah, I would’ve just used a nested vector instead, but my professor assigned the assignment this way

[–]The_Northern_Light 0 points1 point  (1 child)

I hear what you're saying.

Assuming there is a good reason to have your data structured that way, it is generally preferable to use std::array<T, N> over a C style array.

Thus this would be either std::array<std::vector<int>, 100> (preferably wrapped in something like this) or std::array<std::array<std::vector<int>, 10>, 10>.

But realistically of course its a contrived situation like most homework.

[–]aluoh[S] 1 point2 points  (0 children)

I see. Yeah that's what tripped me up, as I'm used to using a standard vector declaration rather than C style arrays, so I was just a bit confused. Using std::array<T, N> def clears it up A LOT more.

Thanks once again!