| Increasing Reusability - Multiple inheritance |
|
|
| Wednesday, 31 January 2001 09:24 | ||||||
Page 4 of 4 Multiple InheritanceIn the Shape class hierarchy, we’ve seen single inheritance, where each class (except the root) has one and only one superclass, though a class can have multiple subclasses. Consider this alternative hierarchy:
A Rectangle is defined as a Quadrilateral with four right (90°) angles, while a Rhombus is a Quadrilateral with four equal sides. A Square has four right angles and four equal sides, so it inherits the properties of both a Rectangle and a Rhombus. This is an example of multiple inheritance. C++ permits multiple inheritance in addition to single inheritance, and it gives a lot of flexibility in coding, as it more accurately models many real-world situations. |
||||||
| Last Updated on Tuesday, 28 October 2008 14:51 |