← Quiz: Memory and Smart Pointers: all 10 questions
Quiz: Memory and Smart Pointers · Question 10 of 10
Which exception does vector::at(i) throw when i is outside the vector?
Which exception does vector::at(i) throw when i is outside the vector?
- A.invalid_argument
- B.bad_alloc
- C.out_of_range
- D.runtime_error
Answer & explanation
Correct answer: out_of_range
at() checks the index and throws out_of_range; operator[] does not check at all.
Can you get the rest right without peeking?
Take the timed Quiz: Memory and Smart Pointers quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →