Objective-C继承(Inheritance)——有关术语

超类(Superclass)

超类是继承的类。Circle的超类是Shape,Shape的超类是NSObject。

The superclass is the class you’re inheriting from. The superclass of Circleis Shape. The superclass of Shape is NSObject.


父类(Parent Class)

父类是超类的另一种表达方式。Shape是Rectangle的父类。

Parent class is another word for “superclass.” For example, Shape is theparent class of Rectangle.


子类(Subclass)

子类是执行继承的类。CircleShape的子类,Shape是NSObject的子类。

The subclass is the class doing the inheriting. Circle is a subclass of Shape,and Shape is a subclass of NSObject.


孩子类(Child Class)

孩子类是子类的另一种表达形式。CircleShape的孩子类。

Child class is another word for “subclass.” Circle is a child class of Shape.It’s your choice whether to use subclass/superclass or parent class/childclass. You’ll come across both pairs in the real world. In this book, we usesuperclass and subclass, possibly because we’re more nerdy than parental.


重写(Override)

如果要改变方法的实现,就需要重写继承的方法。Circle类有自己的draw方法,因此我们说Circle类重写了draw方法。代码运行时,Objective-C会确保调用的总是重写过的方法。

You override an inherited method when you want to change itsimplementation. Circle has its own draw method, so we say it overridesdraw. Objective-C makes sure that the appropriate class’s implementation ofan overridden method is called when the code runs.




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值