Class Inheritance

Unlike structures, classes support inheritance. For example:

Slice
module M
{
class TimeOfDay
{
short hour; // 0 - 23
short minute; // 0 - 59
short second; // 0 - 59
}
class DateTime extends TimeOfDay
{
short day; // 1 - 31
short month; // 1 - 12
short year;
}
}

DateTime inherits the hour, minute, and second fields of TimeOfDay, and adds the fields of a date.

A class can extend only one base class, and a derived class cannot redefine a field of its base class.

All classes implicitly inherit from Value. This way, a Value parameter in an operation accepts any class instance.