题库首页 › GESP等级认证(C++) › 题目 25634

下面代码在 main() 中有一行会导致编译错误,请找出来 #include #include using namespace std; 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; }

A:第 ① 行
B:第 ② 行
C:第 ③ 行
D:第 ④ 行

正确答案:C

试卷来源:202606 CCF-GESP编程能力等级认证C++六级真题

本卷相关题目

在线做题 同科目题库