越界会走哪个分支
运行下面这段程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#include <stdexcept>
int main() {
vector<int> a = {1, 2, 3};
try {
cout << a.at(10) << endl;
} catch (const out_of_range&) {
cout << "越界了" << endl;
}
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论