Question: C++ LANGUAGE class Time { public: Time(); Time(int hrs, int min, int sec); private: int hours; int minutes; int seconds; }; Write the class definition

C++ LANGUAGE

class Time { public: Time(); Time(int hrs, int min, int sec);

private: int hours; int minutes; int seconds; };

  1. Write the class definition for ExtendedTime which derives from Time via public inheritance. Add private data member time_zone which is an enum type TimeZone (enum TimeZone { PACIFIC, MOUNTAIN, CENTRAL, EASTERN } ). Add a default and alternate constructors to ExtendedTime to initialize all class (including the base class) data; use the base member initialization list. NOTE: This implies implementing default, alternate constructors for class Time as well.

  2. Class Invoice contains a private data member purchase_time of type Time. Write default, alternate constructors for Invoice which initializes purchase_time; use the base member initialization list.

  3. We would like to be able to print out dates for class ExtendedTime seamlessly to the console via COUT. Add an overloaded insertion stream operator << to ExtendedTime. Do the same for the Invoice class. You will need to use a friend.

  4. Instantiate ExtendedTime, Invoice objs in client code (passing data to alternate constructors). Print out class data to the console via <<.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!