第28485题 单选题
在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对象后执行排序
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析