新手求助!
这个程序为什么运行结果为1呢?????高手能不能帮我解释解释这个程序,多谢了!#include<iostream>
using namespace std;
class Student
{
public:
static int noOfStudents;
Student &nextStudent()
{
noOfStudents++;
return *this;
}
};
int Student::noOfStudents=0;
void fn(Student &s)
{
cout<<s.nextStudent().noOfStudents<<endl;
}
void main()
{
Student ss;
fn(ss);
}