#include
#include
#include
using namespace std;
typedef struct Point
{
int Subject1; // 语文
int Subject2; // 数学
int Subject3; // 外语
}sPoint, *pPoint;
class Student
{
private:
int number;// 学号
sPoint point; // 分数信息
public:
Student(int iNum, sPoint &sP);// 根据学号、分数生成学生类
void Print()
{
cout << "------------------------" << endl;
cout << " 学号:" << number << endl;
cout << " 语文:" << point.Subject1 << endl;
cout << " 数学:" << point.Subject3 << endl;
cout << " 外语:" << point.Subject2 << endl;
}
friend sPoint operator-(const Student &val1, const Student &val2)
{
sPoint diff;
diff.Subject1 = 0;
diff.Subject2 = 0;
diff.Subject3 = 0;
if( &val1 != &val2 )
{
diff.Subject1 = val1.point.Subject1 - val2.point.Subject1;
diff.Subject2 = val1.point.Subject2 - val2.point.Subject2;
diff.Subject3 = val1.point.Subject3 - val2.point.Subject3;
}
return diff;
}
};
Student::Student(int iNum, sPoint &sP)
{
number = iNum;
point.Subject1 = sP.Subject1;
point.Subject2 = sP.Subject2;
point.Subject3 = sP.Subject3;
}
int main( void )
{
sPoint a, b, c;
a.Subject1 = 60;
a.Subject2 = 70;
a.Subject3 = 80;
b.Subject1 = 90;
b.Subject2 = 80;
b.Subject3 = 70;
Student s1(1, a), s2(2, b);
s1.Print();
s2.Print();
c = s1 - s2;
cout << "------------------------" << endl;
cout << " 语文分差:" << c.Subject1 << endl;
cout << " 数学分差:" << c.Subject3 << endl;
cout << " 外语分差:" << c.Subject2 << endl;
return 0;
}
用什么语言阿
程序的要求是什么?
class Student
{
friend Cheng_i_Cha();
public
Student();
private
int num;
int score;
};
这个不知道楼主满意不?