> For the complete documentation index, see [llms.txt](https://gold.gitbook.io/kotlin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gold.gitbook.io/kotlin/class/open.md).

# open

* Kotlin에서 상속은 "클래스네임 : 상속받을클래스네임()" 의 형태로 작성한다.

```kotlin
open class Foo {
    open val x: Int get { ... }
}

class Bar1 : Foo() {
    override val x: Int = ...  //Property도 override가 가능하다.
}
```

```kotlin
open class Base {
    open fun v() {}
    fun nv() {}
}

class Derived : Base() {
    override fun v() {}
    //open 키워드가 없는 Property와 function은 final이기 때문에 override를 할 수 없다.
}
```

```kotlin
interface Foo {
    val count: Int
}

class Bar1(override val count: Int) : Foo

class Bar2 : Foo {    // interface는 생성자를 필요로 하지 않기 때문에 ()를 붙이지 않는다.
    override var count = 0    // val을 var로도 override할 수 있다. 그 반대는 불가하다.
}
```
