菜鸟问题,大侠进来解释一下下。
逍遥_WX 2002-04-01 04:17:57 #include <iostream.h>
#include <stdlib.h>
class student
{
public:
float Cal_Grade(int tempGrade)
{
return tempGrade;
}
};
class graduate:public student
{
public:
float Cal_Grade(int tempGrade)
{
return 30+tempGrade*0.7;
}
};
float fn(student &x,int tempGrade)
{
return x.Cal_Grade(tempGrade);
}
int main()
{
student s;
graduate gs;
cout<<"The grade of s="<<s.Cal_Grade(80)<<endl;
cout<<"The grade of gs="<<gs.Cal_Grade(80)<<endl;
cout<<"The grade of s="<<fn(s,80)<<endl;
cout<<"The grade of gs="<<fn(gs,80)<<endl;
system("PAUSE");
return 0;
}
运行结果为:
The grade of s=80
The grade of gs=86
The grade of s=80
The grade of gs=80----------------这一个结果不懂,请大侠解释一下。