student.cpp
来自「简易学生管理系统,有删除添加查找编辑修改等功能」· C++ 代码 · 共 42 行
CPP
42 行
#include <iostream>
#include "Student.h"
using namespace std;
Student::Student(unsigned int i, char* n, char g, unsigned int a, double s)
{
id = i;
strcpy(name, n);
gender = g;
age = a;
score = s;
}
bool Student::operator < (const Student &rhs)
{
return this->score < rhs.score;
}
ostream& operator << (ostream& os, const Student& rhs)
{
os << rhs.id << "\t" << rhs.name << "\t"
<< rhs.gender << "\t" << rhs.age << "\t"
<< rhs.score << endl;
return os;
}
istream& operator >> (istream& is, Student& rhs)
{
cout << "Please enter id: ";
is >> rhs.id;
cout << "Please enter name: ";
is >> rhs.name;
cout << "Please enter gender: ";
is >> rhs.gender;
cout << "Please enter age: ";
is >> rhs.age;
cout << "Please enter score: ";
is >> rhs.score;
return is;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?