June 2006
Intermediate to advanced
1344 pages
42h 52m
English
Like methods, constructors of a class can be overloaded. To do so, provide a separate method declaration with the same name (New) for each version of the method but different numbers, types and/or orders of parameters.
The Time constructor in Fig. 9.1 initialized hourValue to 12 and minuteValue and secondValue to 0 (i.e., noon) with a call to the class’s SetTime method. Recall that the declaration in line 4 of Fig. 9.2 supplied no arguments to the Time class constructor. Suppose you would like to create Time objects with any legitimate hour, minute and/or second values. Class Time of Fig. 9.3 includes five overloaded constructors to provide several ways ...
Read now
Unlock full access