Enter the code:
/** Copyright (c) 2015, Yantai University School of Computer * All rights reserved. * File name: Sum123.cpp * Author: Lin Haiyun * Completion date: April 28, 2015 * Version number: v2.0 * * Problem Description: Implement the various operations of the overloaded operator of the time class * Input Description: No * program output: Results of each operation/#inclu De<iostream>using namespace Std;class ctime{private:unsigned short int hour; When unsigned short int minute; Sub unsigned short int second; Seconds public:ctime (int h=0,int m=0,int s=0); void settime (int h,int m,int s); void display (); function definitions For comparison operation overloads bool operator > (CTime &t); BOOL operator < (CTime &t); BOOL operator >= (CTime &t); BOOL operator <= (CTime &t); BOOL operator = = (CTime &t); BOOL operator! = (CTime &t); The definition of the binary function is CTime operator+ (CTime &t); CTime operator-(CTime &t); CTime operator+ (int s);//return S seconds after CTime operator-(int s);//return seconds before time//two mesh assignment operator function definition CTime operator+= (CTime &c) ; CTime operator-= (CTime &c); CTime operator+= (int s);//Returns the time after S seconds CTime operator-= (int s);//returnss seconds before the time}; 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::d isplay () {cout<
Operation Result:
Operator overloading in the time class