#include<iostream>
#include<string>
using namespace std;
class student{
public:
student(int nu,string na,double m);
void disp();
private:
int number;
string name;
double mark;
static int people;
static double sum;
};
int student::people=0;
double student::sum=0;
student::student(int nu,string na,double m)
{
number=nu;
name=na;
mark=m;
people++;
sum+=m;
}
void student::disp()
{
cout<<"学号:"<<number<<endl
<<"姓名: "<<name<<endl
<<"成绩:"<<mark<<endl
<<"人数:"<<people<<endl
<<"总分: "<<sum<<endl;
}
int main()
{
student s1(1,"张三",59);
s1.disp();
student s2(2,"李四",99);
s2.disp();
system("pause");
return 0;
}
4.21
最新推荐文章于 2024-09-05 22:56:27 发布