Step 2 of 7
std::array
std::array<T, N> is a fixed-size array with the size in its type (you built one in the templates module). Compared with a C array it:
- knows its size (
.size()), - doesn't decay to a pointer, so functions receive the whole thing,
- can be copied, compared with
==and returned from functions, - has bounds-checked access with
.at(i), which reports an error instead of silently reading garbage.
Use it whenever the size is fixed and known at compile time.
Your turn: write std::array<int, 3> podium(const std::vector<int>& scores) returning the three highest scores, highest first. Missing places are 0. Don't modify the input.