Skip to content

Instantly share code, notes, and snippets.

@nattybear
Last active January 22, 2021 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nattybear/622171e62e14c941eefb7d90ebd5e095 to your computer and use it in GitHub Desktop.
Save nattybear/622171e62e14c941eefb7d90ebd5e095 to your computer and use it in GitHub Desktop.

이 글은 Canol Gokel님이 만든 Computer Programming using GNU Smalltalk를 읽고 정리한 것이다.

Inheritance

  • 상위 클래스로부터 파생된 클래스를 subclass라고 부른다.
  • 상위 클래스를 superclass라고 부른다.
  • subclass는 superclass의 모든 속성과 행위를 상속 inherit 받는다.
  • 하나의 클래스가 여러 개의 subclass를 가질 수 있지만 여러 개의 superclass를 가질 수는 없다.

객체 간에는 두가지 종류의 관계가 있다.

  • 어느 하나가 다른 클래스에서 파생된 is-a 관계

Car is a Vehicle

  • 객체가 다른 객체로 구성되어 있는 has-a 관계

Vehicle has a Body

여기서 언급한 상속 관계는 has-a를 말하는 것이 아니라 is-a를 말하는 것이다.

Multiple Inheritance and Single Inheritance

어떤 프로그래밍 언어에서는 여러 개의 superclass를 상속할 수 있는데 이런 것을 다중 상속 multiple inheritance라고 한다. 스몰토크처럼 하나의 superclass만 가지는 것을 단일 상속 single inheritance이라고 한다.

Computer Programming with GNU Smalltalk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment