|
|
|
|
|
|
|
Figure 16-4
Class Interface Diagram for Time Class |
|
|
|
|
|
|
|
|
off-the-shelf class on a system, the source code for the implementation is probably unavailable. Even if it is available, modifying it may introduce bugs into a previously debugged solution. Access to the source code also violates a principal benefit of abstraction: users of an abstraction should not need to know how it is implemented. |
|
|
|
|
|
|
|
|
In C++, as in other OOP languages, there is a far quicker and safer way in which to add time-zone features: use inheritance. Let's derive a new class from the Time class and then specialize it. This new, extended time classcall it ExtTimeinherits the members of its base class, Time. Here is the declaration of ExtTime: |
|
|
|
|
|
|
|
|
enum ZoneType {EST, CST, MST, PST, EDT, CDT, MDT, PDT};
class ExtTime : public Time
{
public:
void Set( /* in */ int hours,
/* in */ int minutes,
/* in */ int seconds,
/* in */ ZoneType timeZone );
void Write() const;
ExtTime( /* in */ int initHrs, // Constructor
/* in */ int initMins,
/* in */ int initSecs,
/* in */ ZoneType initZone );
|
|
|
|
|
|