C++程序设计 (第三版) 谭浩强 习题9.6

习题 9.6 阅读下面程序,分析其执行过程,写出输出结果。

代码块:
#include <iostream>
using namespace std;

class Student{
public:
	Student(int n, float s): num(n), score(s){}
	void change(int n, float s){num = n; score = s;}
	void display(){
		cout<<num<<" "<<score<<endl;
	}

private:
	int num;
	float score;
};

int main(){
	Student stud(101, 78.5);
	stud.display();
	stud.change(101, 80.5);
	stud.display();

	system("pause");
	return 0;
}
IDE工具:VS2010
Note: 使用不同的IDE工具可能有部分差异。

 

结果如下:
101 78.5
101 80.5
12-19 15:49