当前位置:网站首页>Differences between overloads, rewrites, abstract classes and interfaces
Differences between overloads, rewrites, abstract classes and interfaces
2022-06-28 05:59:00 【Coder without code】
heavy load :
A way for classes to handle different types of data in a unified way . Multiple functions with the same name exist at the same time , Determine which method to use according to the number and type of incoming data .
Is a manifestation of polymorphism , Its polymorphism is reflected in judging which method to use according to the number and type of incoming data .
, sex : Same method name , The type or number of parameter lists are different , Independent of return value . Two methods with different return values , In the same class is not considered overloaded , Instead, compilation errors will occur .
rewrite :
Polymorphism between parents and children , Redefining the function of the parent class . That is, a method defined in a subclass has the same name and parameters as its parent class .
If a method in a subclass has the same method name as a method in a parent class 、 Return type and parameter list , Then the new method will cover the original method . If you need the original method in the parent class , You can use super keyword , The keyword refers to the parent class of the current class .
The difference between abstract classes and interfaces :
1. Abstract classes are still a kind of class , There's a way to structure , Only inheritance . It's an abstraction of things , Contains properties and behaviors , That is, you can have non abstract methods and member variables .
2. There can only be abstract methods in an interface , Can't instantiate , Can be implemented .
边栏推荐
猜你喜欢
随机推荐
预训练模型参数不匹配
Mysql-17- create and manage tables
Yygh-8-appointment registration
高质量国产立体声编解码器CJC8988,Pin to Pin替代WM8988
RL practice (0) - and the platform xinchou winter season [rule based policy]
Official answers to the "network security" competition questions of the 2022 national vocational college skills competition
Using pytorch and tensorflow to calculate the confusion matrix of classification model
Object object to list collection
sql及list去重操作
CSI以及本地盘的相关实现记录
Lenovo hybrid cloud Lenovo xcloud, new enterprise IT service portal
数据仓库:DWS层设计原则
Simple handwritten debounce function
YYGH-8-预约挂号
How popular are FB and WhatsApp mass messages in 2022?
重载,重写的区别,抽象类,接口的区别
Scripting and programming languages
数据仓库:金融/银行业主题层划分方案
Data warehouse: financial / banking theme layer division scheme
numpy.reshape, numpy.transpose的理解









