0
0

安易な継承の落とし穴

Last updated at Posted at 2024-02-27

継承を行った子クラスは、継承元の親クラスの一種として扱われます。
その為、一部のフィールドやメソッドのみを流用する目的で継承すると、継承されている機能の一部が、誤った用途で使用できてしまう場合があります。
このような事態を避ける為には親クラスと子クラスの関係性に注意する必要があります。

親クラスのメソッド等を子クラスで全て利用する場合は良いですが、親クラスのメソッドを一部使わない場合は注意が必要です。

0
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0