在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Base and Derived Classes: class BaseClass{ class func staticMethod(){ println("BaseClass.staticMethod") } class func staticMethodWithSelfCall(){ self.staticMethod() } func instanceMethodWithStaticCall(){ self.dynamicType.staticMethod() } } class DerivedClass : BaseClass{ override class func staticMethod(){ println("DerivedClass.staticMethod") } } Test Code: BaseClass.staticMethod()
DerivedClass.staticMethod()
BaseClass.staticMethodWithSelfCall()
DerivedClass.staticMethodWithSelfCall()
BaseClass().instanceMethodWithStaticCall()
DerivedClass().instanceMethodWithStaticCall()
Output: BaseClass.staticMethod
DerivedClass.staticMethod
BaseClass.staticMethod
DerivedClass.staticMethod
BaseClass.staticMethod
DerivedClass.staticMethod
|
请发表评论