0
Why is this vector out of bounds?
Please explain https://code.sololearn.com/cbsOBpT5I4kv/?ref=app
3 Respuestas
+ 3
On line 13 - 14:
for (int i = 0; i <= SIZE; i++)
a.at(i) = 8;
You should use < not <=
If you try to access elements at index < 0 or index >= a.size() at method throws std::out_of_range exception
+ 2
Problem's here:
for (int i = 0; i <= SIZE; i++)
Because you use <=, you also ask for a[3] which doesn't exist.