Question: Create a class called clockType for a clock type with fields hr, min, and sec. Your code should support the following set of statements: 1

Create a class called clockType for a clock type with fields hr, min, and sec. Your code should support the following set of statements:

1 clockType c1; 2 clockType c2 (10,59);3 clockType c3(5,10,20);4 int sec = 10; 5 cout << c1; 6 cout << c2 << c3; 7 cout << c1+c2; 8 c1 = c1+sec;

In c2, you only set hr and min fields. Note that the min and sec fields can only support numbers in the range 0 to 60.

Your final submission will need to have four files as follows:

clockType.h clockType.cpp lab1-cmpe126.cpp Notes

The above statements should be in lab1-cmpe126.cpp. Beautify the output as you like it. Discuss the following questions:

What constructors did you need to use? Is one constructor enough?

What is the difference between lines 5 and 6? Do you need special implementation to support

line 6?

Do you need to overload the assignment operator to support any the above operations?

What did you need to do to support line 8? What would happen if you tried cout << sec + c1

instead?

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!