Overriding properties
First, we will try to override the numberOfLegs type property that the Dog class will inherit from the Animal base class. We will face an issue and solve it. The following lines show the code for a simplified version of the Dog class that inherits from DomesticMammal and just tries to override the numberOfLegs type property:
open class Dog: DomesticMammal {
open static override var numberOfLegs: Int {
get {
return 4;
}
}
}
After we enter the previous lines in the Playground, we will see the following error message in the line that tries to override the numberOfLegs type property: error: cannot override static var. The following screenshot shows the error in the Playground. We will see similar error messages in the Swift REPL and in the Swift Sandbox. The code file for the sample is included in the swift_3_oop_chapter_04_05 folder:

Note
When we declare either a type property or a...