This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:cprog:fall2021:projects:oop1 [2021/11/04 18:53] – [A reflection on the concept of inheritance] zswartwo | notes:cprog:fall2021:projects:oop1 [2021/11/05 04:01] (current) – [References] hhemler | ||
---|---|---|---|
Line 82: | Line 82: | ||
Parent/ | Parent/ | ||
+ | |||
+ | It’s also possible to inherit from a class that is itself derived from another class | ||
====A reflection on the concept of inheritance==== | ====A reflection on the concept of inheritance==== | ||
(among other things) | (among other things) | ||
Line 88: | Line 90: | ||
Something Interesting to note is that child class cannot access the private information relating to their parents, but can still have them. For example, if plant(as a parent class of tree) has a private int of age, then tree will also have a private value of age. This is because when inheritance is activated it calls upon the parent' | Something Interesting to note is that child class cannot access the private information relating to their parents, but can still have them. For example, if plant(as a parent class of tree) has a private int of age, then tree will also have a private value of age. This is because when inheritance is activated it calls upon the parent' | ||
+ | |||
+ | When something has multiple parents it is called multiple inheritance. When there is more than one tier of inheritance (grandparents) it is called multilevel inheritance. When something has multiple children it is called hierarchical inheritance. When multiple of these occur it is called hybrid inheritance. | ||
+ | |||
+ | Inheritance allows us to reuse classes by having other classes inherit their members. | ||
+ | |||
+ | It is possible to make a class non-subclassable (sterile) in C++ with the " | ||
COOL BUG FACT: Inheritance was first created for the Simula programming languages | COOL BUG FACT: Inheritance was first created for the Simula programming languages | ||
Line 104: | Line 112: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
- | * https:// | ||
* https:// | * https:// | ||
* https:// | * https:// |