|
#include <iostream.h>
#include <string>
using namespace std;
class student
{
private:
string no;
string name;
float deg1;
float deg2;
float deg3;
static float sum1,sum2,sum3;
static int num;
public:
student(string no,string name,float deg1,float deg2,float deg3)
{
this->no = no;
this->name = name;
this->deg1 = deg1;
this->deg2 = deg2;
this->deg3 = deg3;
sum1+=this->deg1;
sum2+=this->deg2;
sum3+=this->deg3;
num+=1;
}
float avg1()
{
return sum1/num;
}
float avg2()
{
return sum2/num;
}
float avg3()
{
return sum3/num;
}
void disp()
{
cout<<name<<endl;-------------------------------------------->>???这处不明白呀?
cout<<"语文总成绩:"<<sum1<<endl;
cout<<"数学总成绩:"<<sum2<<endl;
cout<<"英语总成绩:"<<sum3<<endl;
}
};
float student::sum1 = 0;
float student::sum2 = 0; |
|