6 Nov 2018: Comparing Objects
Instructions
-
Spend approx 5 minutes reviewing and running the following code:
-
Fork (make a copy of) this repl.it.
-
Create one
Date
object for each group member.-
Each group member should pick a date of personal significance (birthday, etc.), and an associated object name.
-
-
Write a definition for the
equals
member function inDate.h
. -
Use your new member function to compare each object to the others.
-
Use the example code to write a definition for the
greater
member function. -
Write a definition for the
less
member function that usesequals
andgreater
. -
BONUS Write a member function that returns true if the month and day match (i.e., check if the calendar day matches).
8 Nov 2018: Operators and Friend Functions
Instructions
-
Spend approx 5 minutes running and reviewing the following code:
-
Fork (make a copy of) the above repl.it.
-
Add one
cout
statement inside each operator that prints outd1
(the first date). -
Bonus Modify the definition of
operator<
infriend.h
by adding or removing a single!
so that the program prints "Time Warp!"