< previous page page_913 next page >

Page 913
    ExtTime();                                // Default constructor,
                                              //   setting time to
private:                                      //   0;0;0 EST
    ZoneType zone;
};
The opening line
class ExtTime : public Time
states that ExtTime is derived from Time. The reserved word public declares Time to be a public base class of ExtTime. This means that all public members of Time (except constructors) are also public members of ExtTime. In other words, Time's member functions Set, Increment, and Write can also be invoked for ExtTime objects.* However, the public part of ExtTime specializes the base class by reimplementing (overriding) the inherited functions Set and Write and by providing its own constructors.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif 3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Overriding Reimplementing a member function inherited from a parent class.
The private part of ExtTime declares that a new private member is added: zone. The private members of ExtTime are therefore hrs, mins, secs (all inherited from Time), and zone. Figure 16-5 pictures the relationship between the ExtTime and Time classes.
This diagram shows that each ExtTime object has a Time object as a subobject. Every ExtTime is a Time, and more. C++ uses the terms base class and derived class instead of superclass and subclass. The terms superclass and
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif 3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
*If a class declaration omits the word public and begins as class DerivedClass : BaseClass or if it explicitly uses the word private, class DerivedClass : private BaseClass then BaseClass is called a private base class of DerivedClass. Public members of BaseClass are not public members of DerivedClass. That is, clients of DerivedClass cannot invoke BaseClass operations on DerivedClass objects. We do not work with private base classes in this book.

 
< previous page page_913 next page >