18 lines
234 B
Markdown
18 lines
234 B
Markdown
# 위임
|
|
|
|
```kotlin
|
|
interface Base {
|
|
fun print()
|
|
}
|
|
|
|
class BaseImpl(val x: Int) : Base {
|
|
override fun print() { print(x) }
|
|
}
|
|
|
|
class Derived(b: Base) : Base by b
|
|
|
|
fun main(){
|
|
val b = BaseImpl(10)
|
|
Derived(b).print()
|
|
}
|
|
``` |