[kotlin] 추상 클래스를 다중 상속하는 방법
아래는 해당 방법을 사용한 예제 코드입니다:
interface Interface1 {
fun method1()
}
interface Interface2 {
fun method2()
}
abstract class AbstractClass : Interface1 {
fun commonMethod() {
// 공통으로 사용되는 메서드 구현
}
}
class ConcreteClass : AbstractClass(), Interface2 {
override fun method1() {
// Interface1에 정의된 메서드 구현
}
override fun method2() {
// Interface2에 정의된 메서드 구현
}
}
위의 코드에서 AbstractClass는 Interface1을 구현하고, ConcreteClass에서 AbstractClass를 상속하며, Interface2도 구현합니다.
이를 통해 개체가 ConcreteClass를 통해 Interface1 및 Interface2의 메서드와 AbstractClass의 공통 메서드에 액세스할 수 있습니다.