- For this project you are to specify and implement a derived class extclockType from class clockType. The latter is available from the Chapter 01 Source Code/ClockType folder that you get when you install the textbook examples.
- You must derive extclockType as public and you will need to make just one single change to clockType so that the member functions of the former can directly access the data members of the latter. The derived class will have a data member for storing the time zone.
- A description of the components of the extclockType class follows below.
- Holds the time zone as a two-letter word (CT, PT, ET, MT).
- Overloaded operator<<: sends to the standard output device a time in the format HH:MM:SS TZ, where HH is the hour, MM is the minute, SS is the second, and TZ is the time zone. Time zone must be shown in capital letters.
- Overloaded operator>>: reads from the standard input device a time entered by the user as HH:MM:SS TZ, where HH is the hour, MM is the minute, SS is the second, and TZ is the time zone. Note: the user may enter the time zone in upper or lower case but it must be saved in upper case.
- Overloaded operator++ (prefix form): increments the time by one second and returns this value.
- Overloaded operator++ (postfix form): increments the time by one second but returns the previous value (before the increment).
- Overloaded operator==: compares two times based on their hours, minutes, seconds, and time zone. Returns true if all four components for the two times match, false otherwise.
- Overloaded operator+: adds two times and returns the resulting time. If the time zone of the two times is not the same, it prints the message “The time zones are different; the times cannot be added!” and returns 0:0:0 NT (No Time) as the result.
- Parameterized constructor: explicitly invokes the parameterized constructor of class clockType to initialize hours, minutes, and seconds to the values passed by the user and then initializes the time zone data member with the value passed by the user.
- Default constructor: invokes the default constructor of class clockType to initialize hours, minutes, and seconds and then initializes the time zone data member to "CT".
- Since the textbook does not show how to overload the increment operator you will have to get this information from the slides available from Blackboard, other books, the Web, etc. Below are the prototypes of these two operators for your reference.
- extclockType operator++(); //Overload the operator ++ (prefix form)
- extclockType operator++(int); //Overload the operator ++ (postfix form)
bs
By: bs | Date: Oct 2 2007 02:31 | Format: None | Expires: never | Size: 2.56 KB | Hits: 1435
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago