1.何为继承?What is Inheritance?
在上图中,对于车来讲,汽车就是子类。对于汽车来讲,奔驰就是子类。车是汽车的基类,超类,或说父类。到底什么是继承?马克-to-win,子类把父类的方法和属性当成自己的一样随便用的这种现象叫继承。In OOP, the ability that subclass inherits all of the variables and methods defined in the superclass is known as Inheritance.
继承是一种“是”的关系,比如汽车是一种车,奔驰是一种汽车。(It represent is-a relationship)
Syntax(语法)
class SubClassName extends SuperClassName{
…
}
被继承的类叫超类(superclass)。
继承超类的类叫子类(subclass)。
更多请看下节:https://blog.csdn.net/qq_44639795/article/details/103122883
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有