Write a C++ program that has a Time class and an Ltime class. The Time class sho
ID: 3645142 • Letter: W
Question
Write a C++ program that has a Time class and an Ltime class. The Time class should have integer data members named hours, minutes, and seconds, and the Ltime class should have a long integer data member named elsecs, which represents the number of elapsed seconds since midnight. For the Time class, include a conversion operator function named Ltime() that converts a Time object to an Ltime object. For the Ltime class, include a conversion operator function named Time() that converts an Ltime object to a Time object.Explanation / Answer
I left writing the destructor and overloading the minutes operator to you : #include #include using std::cout; using std::setfill; using std::setw; using std::cin; using std::cout; using std::endl; class Time { public: Time( int = 0, int = 0, int = 0 ); // default constructor const Time Time::operator+(const Time &other) ; void setTime( int, int, int ); // set time void setHour( int ); // set hour void setMinute( int ); // set minute void setSecond( int ); // set second int getHour() const; // return hour int getMinute() const; // return minute int getSecond() const; // return second void Time::get( ); void Time::show(); private: int hour; // 0 - 23 (24-hour clock format) int minute; // 0 - 59 int second; // 0 – 59 }; Time::Time( int hour, int minute, int second ) { setTime( hour, minute, second ); } void Time::setTime( int hour, int minute, int second ) { setHour( hour ); setMinute( minute ); setSecond( second ); } void Time::get( ) { int hour, minute, second; cout > hour; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.