Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
#include
using namespace std; int main() { // Create a vector called cars that will store strings vector
cars = {"Volvo", "BMW", "Ford", "Mazda"}; // Try to access an element that does not exist (will throw an exception) cout << cars.at(6); return 0; }
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 6) >= this->size() (which is 4)