In swift, inheritance is the basic feature of district classification and other objects
Inherited subclasses can override methods of the parent class, including class methods and instance methods, properties, and satellite scripts (subscript)
In the inheritance process, the constructor method Init () is not inherited and needs to be displayed
Class Tandem:bicycle {init () {super.init () Maxpassengers = 2}
}
Subclasses can only change the properties of variables inherited from the parent class, and cannot change the constant let property
About overriding override
Overriding method: The ability to override the parent class by using the Super.function method
Overriding properties:
When you rewrite a property, it is necessary to write its name and type. This enables the compiler to check that the property you override is matched to a property of the same type in the superclass.
After you provide a setter method in the Override property, you must provide a Get method
Override Property Watcher: Applies to variables, and is either a variable or a read-only computed property.
Because constants and read-only types are not able to be altered. So there is no need to see if its value will change.
At the same time. It is not possible to provide rewrite setters and override property observers at the same time. Because both are meant to observe the change in value. With the setter method, the quality changes can be monitored in real time without the need for a property observer to see if the value changes.
Assume that you do not want some methods, properties, and subscript to be overridden. By adding @final in front, you can
Swift Learning Notes (iv) Inheritance of classes