Skip to content · ⁨コンテンツへスキップ⁩

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.)

日本語

既存のクラスに基づく構築

  • 継承は新しいクラスが既存のクラスを再利用することを可能にします。
  • 新しいクラスはサブクラス(子)、元のクラスはスーパークラス(親)です。
  • class Bird(Animal):を記述します——BirdはAnimalの全てのメソッドを取得します。(試験用擬似コード:CLASS Bird INHERITS Animal。)

Animal親にdescribe()があり、BirdとCowが継承してメソッドを追加または上書きしています

Handout · ⁨プリント⁩

Log in or create account · ⁨ログインまたはアカウント作成⁩

IGCSE, A-Level & AP