2019-05-28 15:02
Package: property and realize hidden object details, external provide public access way to prevent arbitrary access and modify data.
Inheritance: by extending an existing class, and inherits the properties and behavior of the class, to create a new class.
Polymorphism:
three conditions:
1. The satisfied inheritance
2. parent class reference variable subclass object point
3. The method of subclasses of the parent class rewritable
Subclass is converted into the parent rules:
将一个父类的引用指向一个子类的对象,称为向上转型(upcastiog),自动进行类型转换.
此时通过父类引用调用的方法是子类覆盖或继承父类的方法,不是父类的方法.
此时通过父类引用变量无法调用子类特有的方法.
If the parent class to call a specific subclass will have a pointer to the subclass object assigns a reference to a parent class subclass references referred downward transition, this time must be cast. (Sub-class object receiving a pointer to the parent object class subclass reference)