<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Inheritance on Kelly Dev</title><link>https://kelly-chui.github.io/tags/inheritance/</link><description>Recent content in Inheritance on Kelly Dev</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Thu, 08 Jun 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://kelly-chui.github.io/tags/inheritance/index.xml" rel="self" type="application/rss+xml"/><item><title>The Swift Programming Language. Inheritance (1)</title><link>https://kelly-chui.github.io/posts/the-swift-programming-language-18-inheritance-1/</link><pubDate>Thu, 08 Jun 2023 00:00:00 +0000</pubDate><guid>https://kelly-chui.github.io/posts/the-swift-programming-language-18-inheritance-1/</guid><description>&lt;figure class="theme-image"&gt;
&lt;img
class="theme-image__image theme-image__image--light"
src="https://kelly-chui.github.io/images/assets/swift-logo-light.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;img
class="theme-image__image theme-image__image--dark"
src="https://kelly-chui.github.io/images/assets/swift-logo-dark.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;/figure&gt;
&lt;h2 id="inheritance"&gt;Inheritance&lt;/h2&gt;
&lt;p&gt;클래스는 메소드, 프로퍼티등 클래스의 특성들을 다른 클래스에서 상속 받을 수 있다. 한 클래스가 다른 클래스로부터 상속을 받았을 상속 받은 클래스를 &lt;em&gt;서브클래스&lt;/em&gt; 라고 하고, 상속 해준 클래스를 &lt;em&gt;슈퍼클래스&lt;/em&gt; 라고 한다. 상속은 클래스가 다른 타입들과 구별되는 중요한 특성이다.&lt;/p&gt;
&lt;p&gt;스위프트에서 서브클래스는 슈퍼클래스의 메소드, 프로퍼티, 서브스크립트를 접근하고, 호출할 수 있다. 그리고 이러한 메소드, 프로퍼티, 서브스크립트를 오버라이딩 하여 자신에 적합하게 동작을 수정할 수도 있다. 스위프트는 오버라이드한 정의가 슈퍼 클래스의 정의에 매치되는지 확인함으로써 오버라이드가 정확하게 되도록 도와준다.&lt;/p&gt;</description></item><item><title>The Swift Programming Language. Inheritance (2)</title><link>https://kelly-chui.github.io/posts/the-swift-programming-language-19-inheritance-2/</link><pubDate>Thu, 08 Jun 2023 00:00:00 +0000</pubDate><guid>https://kelly-chui.github.io/posts/the-swift-programming-language-19-inheritance-2/</guid><description>&lt;figure class="theme-image"&gt;
&lt;img
class="theme-image__image theme-image__image--light"
src="https://kelly-chui.github.io/images/assets/swift-logo-light.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;img
class="theme-image__image theme-image__image--dark"
src="https://kelly-chui.github.io/images/assets/swift-logo-dark.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;/figure&gt;
&lt;h3 id="overriding"&gt;Overriding&lt;/h3&gt;
&lt;p&gt;서브클래스는 상속 받을 수 있는 인스턴스 메소드, 타입 메소드, 인스턴스 프로퍼티, 타입 프로퍼티, 서브스크립트에 자신만의 커스텀 구현을 할 수 있다. 이것을 &lt;em&gt;오버라이딩&lt;/em&gt; 이라고 한다.&lt;/p&gt;
&lt;p&gt;상속될 수 있는 특성을 오버라이드 하려면, 오버라이드를 하고 있는 정의 앞에 override 키워드를 붙인다. 이렇게 하면 실수로 중복 정의를 한 것이 아닌 오버라이드 했다는 것을 명확하게 보여줄 수 있다. 실수로 오버라이드 하는 것은 예측하지 못한 결과를 가져온다. 따라서 override 키워드 없이 오버라이드를 하면 컴파일할 때 에러로 검출된다.&lt;/p&gt;</description></item></channel></rss>