运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,深色/浅色
前往 Spaces
#include <iostream> #include <vector> using namespace std; int main() { // Create a vector called cars that will store strings vector<string> cars = {"Volvo", "BMW", "Ford", "Mazda"}; // Try to access an element that does not exist (will throw an exception) cout << cars.at(6); return 0; }
抛出 'std::out_of_range' 异常后调用终止
what(): vector::_M_range_check: __n (值为 6) >= this->size() (值为 4)