Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

5. Identify and describe nine social and cultural identities.

Answered: 1 week ago

Question

2. Define identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago