#include<iostream>
using namespace std;
class student{
public:
student(float score1);
void account();
static void sum()
{
cout<<"总成绩为:"<<total_score<<endl;
}
static void average()
{
double aver;
aver=total_score/count;
cout<<"平均分为:"<<aver<<endl;
}
private:
float score;
static float total_score;
static int count;
};
student::student(float score1)
{
score=score1;
}
void student::account()
{
total_score+=score;
count++;
}
float student::total_score=0.0;
int student::count=0;
int main()
{
student s1(90),s2(92),s3(94);
s1.account();
s2.account();
s3.account();
student::sum();
student::average();
system("pause");
return 0;
}
实验四
最新推荐文章于 2022-06-23 14:00:52 发布