【发布时间】:2019-10-21 12:03:14
【问题描述】:
我正在快速学习一些东西。我使用的是 Swift 4 版本。
我正在尝试做一些方法覆盖的事情。
class cricket {
func print() {
print("Super class called")
}
}
class tennis : cricket {
override func print() {
print("Sub class called")
}
}
let circInstance = cricket()
circInstance.print()
let tennisInstance = tennis()
tennisInstance.print()
但是,如果我在我的 Xcode 操场上运行上面的程序,在打印语句时会出现以下错误。
error: MyPlayground.playground:508:15: error: argument passed to call that takes no arguments
print("Super class called")
~^~~~~~~~~~~~~~~~~~~~~
error: MyPlayground.playground:514:15: error: argument passed to call that takes no arguments
print("Sub class called")
~^~~~~~~~~~~~~~~~~~~
有什么建议吗?
【问题讨论】:
标签: ios swift swift4 swift-playground