class inheritance
{
def a()
println("Version 1")
}
class inheritance1
{
def b()
println("version 2")
}
class inheritance2 extends inheritance
{
def c()
println("version 3")
}
class inheritance3 extends inheritance2
{
def d()
println("version 4")
}
object inherited
{
def main(args: Array[String])
{
var obj = new inheritance3
obj.d
obj.c
}
}
它拋出了幾個錯誤:斯卡拉繼承:爲什麼我必須定義我的類是抽象的?
class inheritance needs to be abstract since method a is not defined
class inheritance1 needs to be abstract since method b is not defined
class inheritance2 needs to be abstract since it has two unimplemented members
class inheritance3 needs to be abstract since it has two unimplemented members
定義的方法呢? – Dima
感謝您的答覆,但請準確 –