测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A18449. 下面代码在 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 …

单选题 困难

题目描述

下面代码在 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;
}

选项(单选)

上一题 下一题