Question
C++ class Time { public: Time(); Time(int hrs, int min, int sec); private: int hours; int minutes; int seconds; }; 1. Write the class definition
C++
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. HW03EC Base Init List, Overloading & Friends [+10%]
4. Instantiate ExtendedTime, Invoice objs in client code (passing data to alternate constructors). Print out class data to the console via <<.
C++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started