«
^
»
6.2. Providing a constructor for cloning
Because a
clone
method is difficult to get right, it is also difficult to teach.
So, to begin with, I cheat by teaching students to provide a constructor that can be used for cloning:
public Date(final Date pDate) { iYear = pDate.iYear; iMonth = pDate.iMonth; iDay = pDate.iDay; }