#include<iostream>
#include<string>
using namespace std;
class student{
public:
student(string a,int b,int c);
void show()
{
cout<<"name:"<<name<<" id:"<<id<<" score:"<<score<<" test:"<<test<<" number:"<<number<<" ave:"<<ave<<endl;
}
private:
string name;
int id;
int score;
static int test;
static int number;
int ave;
};
student::student(string a,int b,int c)
{
name=a;
id=b;
score=c;
test=test+score;
++number;
ave=test/number;
}
int student::test=0;
int student::number=0;
int main()
{
student k1[2]={
student("xiaoming",20141165,95),
student("wanghan",20141164,85)
};
for(int i=0;i<2;i++)
k1[i].show();
system("pause");
return 0;
}
4.21
最新推荐文章于 2025-04-21 11:51:00 发布