继承
class Animal
{
abstract int maxSize(); // must be implemented by sub-class
final float maxSizeInMeters() // can't be overridden by base class
{
return maxSize() / 100.0;
}
}
class Lion: Animal
{
override int maxSize() { return 350; }
}
void main()
{
import std.stdio : writeln;
auto l = new Lion();
assert(l.maxSizeInMeters() == 3.5);
writeln(l.maxSizeInMeters()); // 3.5
}