第38921题 单选题
下面代码在 main() 中有一行会导致编译错误,请找出来。
class Student {
public:
    Student(string n, int s) : name(n), score(s) {}

    string getName() {
        return name;
    }

    void setScore(int s) {
        score = s;
    }

private:
    string name;
    int score;
};

int main() {
    Student stu("Tom", 85);
    cout << stu.getName(); // ①
    stu.setScore(90); // ②
    stu.score = 100; // ③
    cout << stu.getName(); // ④
    return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析