Question: The pre - and post - increment operators are similar to the add operations, but, as unary operators, each of them adds a single minute

The pre- and post-increment operators are similar to the add operations, but, as unary operators, each of them adds a single minute to the time stored in the calling object. Recall that the difference between pre- and post-increment operators is essentially that the pre-increment operator changes the calling object and then returns a reference to it, while the post-increment operator copies the calling object and returns its original value after changing the original object.
Hints
Suggested order
I'd suggest writing these operators in the following order:
Output operator (<<): Testing every other operator is easier when you can print the result, and it's easy to declare and initialize Time objects
Input operator (>>): This operator is only used in the first two test cases--we don't combine input tests with any other operator tests--but moving on to this one is a logical extension of the output operator.
Comparison operators (==,!=,<,>): All of these operators are similar, and checking how two Times compare to one another is relatively straightforward.
Arithmetic operators (+,-,+=,-=): Understanding how to correctly add and subtract Time objects is the hardest part of this assignment, in my opinion. There are a couple of special cases to account for, as described below. I recommend handling the simple + and - operators before the augmented assignments += and -=.
Increment operators (++): The increment operators are definitely simpler than the add and subtract operators, but you have to understand addition to write these correctly.

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 Programming Questions!