Object-oriented modeling --- up, reload and rewrite

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_44779847/article/details/102732588

1. The shape up:
1) super type reference to an object of a derived class
2) can point out what, to see the type of reference
rewrite 2. The method of (Override): re-write, covering
1) occurs in the parent-child class, method same name, same parameter list, a different method body
2) when overridden method is called, see the type of object
3) rewrite should follow the "two with a big two small" principle: ------ Learn
3.1) with two :
same as 3.1.1) method name
parameter list 3.1.2) the same
3.2) for two hours:
return value less than or equal superclass method 3.2.1) derived class method
when 1) void, must be equal to
2) basic data types when must equal
3) reference data types, or less
after 3.2.2) less than or equal -------- abnormal abnormality superclass method derived class method throws speaking
3.3) a large:
3.3. access 1) derived class method is greater than or equal to the superclass method of speaking tomorrow ------
3. rewrite the difference between overloading: ------------ common interview questions
1) can be rewritten (override):
1.1) occurs in the parent-child class, the name of the same method, the same parameter list, a different method body
1.2) follow the "runtime binding", to invoke methods according to the type of object
2) overload (Over Load):
2.1) occurs in a class, the same method name, a list of the different parameters, a different method body
2.2) follow the "compile-binding", to bind parameter method / type of reference

Guess you like

Origin blog.csdn.net/qq_44779847/article/details/102732588