interface Demo {
//抽象属性,默认是 public abstract
var id: Long
//抽象方法,默认是 public abstract
fun show()
//能有具体实现的普通函数
fun method() = println("Hello World!")
}
class Haha:Demo{
override var id: Long
get() = TODO("Not yet implemented")
set(value) {}
override fun show() {
TODO("Not yet implemented")
}
}
abstract class Demo() { abstract var id:Long abstract fun method() abstract fun show():Int}声明抽象使用 abstract 关键字。抽象类默认是open的无需声明,其中的抽象属性和抽象函数只有声明而没有实现,子类必须全部重写带有 abstract 修饰的抽象成员。abstract class Demo() { abstract var id:Long abst..