📄 student.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -