?。。。。。。。。。。

 

代码参考如下:


#include <iostream>
using namespace std;

class Student
{
private:
	int mId;
	int mScoreMath;
	int mScoreEng;
	int mScoreC;
public:
	Student(){}
	Student(int id){mId = id;}
	Student(int id,int m,int e,int c){mId = id;mScoreMath=m;mScoreEng=e;mScoreC=c;}
	Student(Student &s){mId = s.getId();mScoreMath = s.getMath();mScoreEng=s.getEnglish();mScoreC = s.getC();}
	~Student(){}
	void setId(int id){mId=id;}
	int getId(){return mId;}
	void setMath(int m){mScoreMath = m;}
	int getMath(){return mScoreMath;}
	void setEnglish(int e){mScoreEng = e;}
	int getEnglish(){return mScoreEng;}
	void setC(int c){mScoreC = c;}
	int getC(){return mScoreC;}
	void setScore(int m,int e,int c){mScoreMath = m;mScoreEng = e;mScoreC = c;}
	
	float average()	{return (mScoreC + mScoreEng + mScoreMath)/3.0;}
	int sum(){return mScoreC + mScoreEng + mScoreMath;}
	void print(){cout << "学号:" << mId << "  数学:" << mScoreMath<< "  英语:" << mScoreEng << "  C语言:" << mScoreC <<endl;}
};

int main()
{
	Student st(1001);
	st.setScore(88,98,89);
	cout << "平均分:" << st.average() << endl;
	cout << "总分:" << st.sum() << endl;
	st.print();


	Student* p = new Student();
	p->setId(1002);
	p->setMath(87);
	p->setEnglish(88);
	p->setC(88);
	cout << "平均分:" << p->average() << endl;
	cout << "总分:" << p->sum() << endl;
	p->print();

	Student st2(st);
	cout << "平均分:" << st2.average() << endl;
	cout << "总分:" << st2.sum() << endl;
	st2.print();
	

	Student a[2];
	a[0] = Student(1004,11,11,11);
	a[1] = Student(1005,22,22,22);

	return 0;

}