#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
Student() {}
Student( const string& nm, int sc = 0 ): name(nm), score(sc){}
//(1)下面的const干神马?_____________
void set_student( const string& nm, int sc = 0 )
{
name = nm;
score = sc;
}
//(2)下面的const分别干神马?___________
const string& get_name() const
{
return name;
}
int get_score() const
{
return score;
}
private:
string name;
int score;
};
//(3)下面的const干神马?_____________
void output_student(const Student& student )
{
cout << student.get_name() << "\t";
cout << student.get_score() << endl;
}
int main()
{
Student stu( "Wang", 85 );
output_student( stu );
return 0;
}
大一第二学期第5周【程序阅读(4)】
最新推荐文章于 2015-05-30 17:26:43 发布