Introduction to OOP
Chapter 13: Multiple Inheritance:
next
previous
audio
real
text
Possible Solutions
1.
Make Number subclass of Magnitude, but redefine comparison operators in class complex to give error message if used. (
subclassing for limitation
)
2.
Don't use inheritance at all - redefine all operators in all classes. (
flattening the inheritance tree
).
3.
Use part inheritance, but simulate others - use Number, but have each number implement all relational operators.
4.
Make Number and Magnitude independent, and have Integer inherit from both. (
multiple inheritance
).
Intro OOP,
Chapter 13
, Slide 05