这是代码:
class Test<T> {
func foo<S:SequenceType where S.Generator.Element == T>(par : S){
print("foo")
}
}
class TestInh : Test<Int> {
override func foo<S:SequenceType where S.Generator.Element == Int>(par : S) {
print("loo")
}
}
Run Code Online (Sandbox Code Playgroud)
它大喊这样的错误:
repl.swift:8:19: error: method does not override any method from its superclass
override func foo<S:SequenceType where S.Generator.Element == Int>(par : S) {
~~~~~~~~ ^
Run Code Online (Sandbox Code Playgroud)
我怎样才能覆盖超类中的方法Test<Int>?
==================额外=======================
谈到代码打击.
class Test<T> {
func foo(par : T){
print("foo")
}
}
class TestInh : Test<Int> {
override func foo(par …Run Code Online (Sandbox Code Playgroud)