在C++中,我们需要对存储`Student`结构体的`std::vector`按照成员变量`id`升序排序,以下代码片段中可以正确完成该需求且无未定义行为的是?
已知Student结构体定义如下:
struct Student {
int id;
std::string name;
Student(int i, std::string n) : id(i), name(n) {}
};
std::vector<Student> vec;
// 向vec中插入若干Student对象后执行排序
正在加载题目数据…
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析