设为首页 加入收藏

TOP

c++实验总结 学生比大小
2017-04-28 10:23:05 】 浏览:323
Tags:实验 总结 学生 大小

c++实验总结  学生比大小:鉴于周五有c++模拟考试。。又是小崔出的全新的题目。。所以总结一下以前做过的实验和学过的重要的知识点或者。

学生比大小,没啥坑。就是实验的测试用例不完全最开始的答案有bug重新改了之后应该没问题了。

#include 
  
   
#include
   
     using namespace std; class Student { public: string name; int age; Student() { name=""; age=0; } int operator>(Student another) { if(age>another.age) return 1; else if(age==another.age) { int i=0; while(i!=name.size()||i!=another.name.size()) { if(name[i]>another.name[i]) return 1; else if(name[i]==another.name[i]) i++; else return 0; } } } friend ostream& operator<<(ostream& os,Student& another); friend istream& operator>>(istream& is,Student& another); }; ostream& operator<<(ostream& os,Student& another) { cout<
    
   
  
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C++之操作符重载及实现简单的复数.. 下一篇C语言编码转换 负数的二进制表示..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目