代码:
//重写类方法
class A {
func printStr(){
print("This is Str")
}
}
class B: A {
override func printStr() {
print("This is not Str")
}
}
let bvalue = B()
bvalue.printStr()
输出:
This is not Str
Program ended with exit code: 0
代码:
//重写类方法
class A {
func printStr(){
print("This is Str")
}
}
class B: A {
override func printStr() {
print("This is not Str")
}
}
let bvalue = B()
bvalue.printStr()
输出:
This is not Str
Program ended with exit code: 0