February 2014
Beginner
1248 pages
62h 25m
English
Lines 12–15 declare a so-called no-argument constructor that’s invoked without arguments. Once you declare any constructors in a class, the compiler will not provide a default constructor. This no-argument constructor ensures that class Time2’s clients can create Time2 objects with default values. Such a constructor simply initializes the object as specified in the constructor’s body. In the body, we introduce a use of this that’s allowed only as the first statement in a constructor’s body. Line 14 uses this in method-call syntax to invoke the Time2 constructor that takes three parameters (lines 30–44) with values of 0 for the hour, minute and second. Using this as shown ...
Read now
Unlock full access