February 2016
Beginner to intermediate
500 pages
187h 36m
English
Time Class Case Study: Overloaded ConstructorsAs you know, you can declare your own constructor to specify how objects of a class should be initialized. Next, we demonstrate a class with several overloaded constructors that enable objects of that class to be initialized in different ways. To overload constructors, simply provide multiple constructor declarations with different signatures.
Time2 with Overloaded ConstructorsThe default constructor for class Time1 (Fig. F.1) initialized hour, minute and second to their default 0 values (which is midnight in universal time). The default constructor does not enable the class’s clients to initialize the time with specific nonzero values. Class Time2 (Fig. F.5) contains five overloaded ...
Read now
Unlock full access