open class Person {
constructor(address: String) {
println("Person Address: $address")
}
constructor(address: String, birthday: String) {
println("Person Address: $address, Birthday: $birthday")
}
}
class MemberPerson : Person {
constructor(address: String) : super(address) {
println("MemberPerson Address: $address")
}
constructor(address: String, birthday: String) : super(address, birthday) {
println("MemberPerson Address: $address, Birthday: $birthday")
}
}
fun main() {
//val person1 = Person("123 Main St")
//val person2 = Person("123 Main St", "01/01/1990")
val member1 = MemberPerson("456 Elm St")
val member2 = MemberPerson("456 Elm St", "02/02/1992")
}
// 결과
Person Address: 123 Main St
Person Address: 123 Main St, Birthday: 01/01/1990
Person Address: 456 Elm St
MemberPerson Address: 456 Elm St
Person Address: 456 Elm St, Birthday: 02/02/1992
MemberPerson Address: 456 Elm St, Birthday: 02/02/1992
super
로 부모 클래스 Person
생성자 상속.