Inheritance
Classes marked with open can be inherited. Use the <: symbol (note, not :) to declare inheritance relationships. Subclass constructors must call the parent class constructor through super(...) to complete initialization of parent class members.
Cangjie uses single inheritance: a class can only have one direct parent class. Inheritance forms an "is-a" relationship—subclass objects can be used as parent class objects. This allows us to store multiple subclass objects in an Array<ParentClass> and automatically call the correct implementation at runtime (polymorphism).
The Dog and Cat classes below inherit from Animal and both override the speak() method. Two subclass objects are stored in the same array, each exhibiting different behavior when iterated.
Subclass constructors must call the parent class constructor. If super(...) is not explicitly called, the compiler will attempt to call the parent class's parameterless constructor.
Try adding a Fish subclass and make its speak() return "Blub blub".