본문 바로가기

Inheritance & encapsulation

English

Build on an existing class

  • Inheritance lets a new class reuse an existing one.
  • The new class is the subclass (child); the original is the superclass (parent).
  • Write class Bird(Animal): — Bird gets all of Animal's methods. (In exam pseudocode: CLASS Bird INHERITS Animal.)

An Animal parent with describe(); Bird and Cow inherit it, adding or overriding methods

교재 자료

로그인 또는 계정 만들기

IGCSE, A-Level & AP