我们要求做一个学生类的程序,谁能给一个简单的实例呀!我想参考一下,谢了!

来源:百度知道 编辑:UC知道 时间:2024/05/16 14:48:57
在程序中最好包括学生学号提取和成绩的基本运算,还有包含友元函数,作用是:计算人两个学生某科成绩差!用的是c++,简单的程序就行,我只想参考一下,谢谢各位大哥大姐们了!

#include <stdio.h>
#include <string.h>
#include <iostream>

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;
dif