重载流运算符
来源:互联网 发布:php邀请码生成算法 编辑:程序博客网 时间:2024/06/05 04:49
#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;class Student{public:int id;string name, grade;Student(){};Student(int id, string name, string grade);friendistream & operator >> (istream & in, Student & s);friend ostream & operator << (ostream & out, Student & s);bool operator < (const Student & s) const;};istream & operator >> (istream & in, Student & s){in >> s.id >> s.name >> s.grade;return in;}ostream & operator << (ostream & out, Student & s){out << s.id << " " << s.name << " " << s.grade << endl;return out;}bool Student:: operator < (const Student & s) const{return this->id < s.id;}/*请在这里填充代码*/int main(){vector<Student> sv;Student temp;while (cin >> temp){sv.push_back(temp);}sort(sv.begin(), sv.end());for (int i = 0; i < sv.size(); ++i)cout << sv[i];return 0;}
0 0
- 流运算符重载
- 重载流运算符
- 流运算符重载
- 重载流运算符
- 重载流插入运算符
- 重载流提取运算符
- 运算符重载 [++,--,+,<<; &&,||(不可重载)]
- 重载之运算符重载
- 运算符重载-流插入运算符和流提取运算符的重载
- 重载之重载流插入和流提取运算符
- c++ 构造函数重定义 + 运算符重载、流重载
- 运算符重载(复数运算(+、-、*重载),输入、出类对象(流类运算符>>/<<的重载))
- 重载流插入/流提取运算符
- 重载运算符和输入输出流
- 重载“流提取运算符—— >> ”
- C++重载运算符和输入输出流
- C++ 流输入输出运算符重载
- C11-2 重载流运算符
- Uva 10269 Adventure of Super Mario(最短路)
- Cookie 会话机制
- sqoop增量导入且表无主键
- C语言输入一串数据到数组中,用空格隔开回车结束
- 做运营和做旅行计划有什么异曲同工之处?
- 重载流运算符
- UnityShader实例:遮挡透明材质
- JS typeof()
- Session 机制
- Linux中find命令,与exec合用,按修改时间查询等
- Css Hack(ie6-9,firefox,chrome,opera,safari)
- 配合Fragment实现 再点一次退出
- Android沉浸式以及解决虚拟键问题
- oracle 替换clob里面的某个特定的字符串