对象的引用
#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;
};
void fun(Student &stud)
{
stud.display();
stud.change(101,80.5);
stud.display();
}
int main()
{Student stud(101,78.5);
fun(stud); /*这里为什么不能写成void fun(Student stud);我觉得这样写类型不是更加的明确吗*/
return 0;
}