Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions