Menu

[Solved] Overload Clocktype Class Follows 1 Adds Two Times Together E 23 59 0001 00 0500 59 05 2 Su Q37281701

Need help making the following program assignment in C++

Overload +, -,--, ! >> and<< for the clockType class as follows: 1. + Adds two times together i.e. 23:59:0001:00:0500:59:05 2

class clockType public: void setTime (int hours, int minutes, int seconds) void printTime () const; bool operator-(const cloc

Overload +, -,–, ! >> and<< for the clockType class as follows: 1. + Adds two times together i.e. 23:59:0001:00:0500:59:05 2. – Subtracts two times i.e. 23:15:10 02:05:05 21:10:05 3.already given in the text book. 4.-you write 5. >> stream input operator i.e. cin >>yourTime (user would be prompted for hr::mm:ss) 5. < stream output operator i.e. cout <myTime would give 23:59:00 Submit code with the following screen shots. 1. Create 4 times with the following values clockType myClock(0, 34, 10); clockType yourClock(0, 24, 50); clockType tempClock(1, 0, 25); clockType newClock; Test all of your new overloaded operators. 2. Provide screenshot of the following a. myClockyourClock; myClock tempClock; b. myClock!-yourClock; myClock !- tempClock; cin>>myClock c. ; d. newClock- myClock +yourClock; cout << newClock; e. newClock yourClock – tempClock; cout << newClock; class clockType public: void setTime (int hours, int minutes, int seconds) void printTime () const; bool operator-(const clockType&otherClock) const //Overload the operator – clockType (int -0o, int-0, int-0) private: int hr int min int sec Next we must write the definition of the function operator–, which is: bool clockType: :operator(const clockType& otherClock) const return (hr _ otherClock.hr && min == otherClock.min && secotherClock.sec) Notice that the body of the function operator-is the same as the body of the function equalTime given in Chapter 10. Also, the definitions of other functions of the class clockType are the same as given in Chapter 10. Show transcribed image text Overload +, -,–, ! >> and stream input operator i.e. cin >>yourTime (user would be prompted for hr::mm:ss) 5. myClock c. ; d. newClock- myClock +yourClock; cout

Expert Answer


Answer to Overload +, -,–, ! >> and> stream input operator i.e. cin >>yourTime (user would be prompted for hr::mm:ss) 5. < stream... . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *