8.2
来源:互联网 发布:电脑编程入门教程 编辑:程序博客网 时间:2024/06/02 14:52
#include <iostream>using namespace std;class CTime{private: unsigned short int hour; // 时 unsigned short int minute; // 分 unsigned short int second; // 秒public: CTime(int h=0,int m=0,int s=0); void setTime(int h,int m,int s); void display(); bool operator > (CTime &t); bool operator < (CTime &t); bool operator >= (CTime &t); bool operator <= (CTime &t); bool operator == (CTime &t); bool operator != (CTime &t); //二目运算符的重载 //返回t规定的时、分、秒后的时间,例t1(8,20,25),t2(11,20,50),t1+t2为:41:15 CTime operator+(CTime &t); CTime operator-(CTime &t);//对照+理解 CTime operator+(int s);//返回s秒后的时间 CTime operator-(int s);//返回s秒前的时间 //赋值运算符的重载 CTime operator+=(CTime &c); CTime operator-=(CTime &c); CTime operator+=(int s);//返回s秒后的时间 CTime operator-=(int s);//返回s秒前的时间};//构造函数CTime::CTime(int h,int m,int s){ hour=h; minute=m; second=s;}void CTime::setTime(int h,int m,int s){ hour=h; minute=m; second=s;}void CTime::display(){ cout<<hour<<':'<<minute<<':'<<second<<endl;}bool CTime::operator > (CTime &t) { if (hour>t.hour) return true; if (hour<t.hour) return false; if (minute>t.minute) return true; if (minute<t.minute) return false; if (second>t.second) return true; return false;}bool CTime::operator < (CTime &t)// 判断时间t1<t2{ if (hour<t.hour) return true; if (hour>t.hour) return false; if (minute<t.minute) return true; if (minute>t.minute) return false; if (second<t.second) return true; return false;}
0 0
- 8.2
- 8.2
- 8.2
- 8.2
- 8.2
- 8.2
- 8.2 Types
- Navicat 8.2
- 8.2 stair
- 8.2 sum
- 8.2 minval
- 8.2.Warshall
- week 8.2
- 8.2反思
- 8.2 数据库
- list_manual_GCC_4.8.2
- 基数排序(8.2)
- 8.2 喀迈拉
- hibernate中实体类的id设置
- linux driver下的DELAY
- 'libxml/HTMLparser.h' not found
- [leetcode]Longest Common Prefix
- cmake to visual studio project
- 8.2
- TCP/IP协议复习-概述
- LINUX DRIVER DELAY FUCTION
- C++ 数组名与指针的区别与用法
- Linux内存管理
- 关于TreeSet的元素改变field后的删除
- Sizeof与Strlen的区别与联系
- 第一讲:Excel在测试活动中的应用
- 第二讲:Excel 在测试中的应用