This preview shows page 1. Sign up to view the full content.
Unformatted text preview: e “duplicated” in D x Possible solution: control how identical attributes are handled In C++, by default, they are replicated If the inheritance is declared “virtual” then they are merged Be careful: other OO languages may have different default implementations! x Strong advise: do not do multiple inheritance unless you know what
you are doing
you You probably want to use interfaces and not class inheritance You want to avoid any diamond shape in the inheritance graph
143 Some guidelines to determine a good hierarchy
x RULE 1)
If A : B in the hierarchy, then the sentence “A is a
RULE B” should make full sense
x Example: “a rectangle is a square” vs. “a rectangle is an
object” Meaningful design may not lead to maximal code reuse x RULE 2)
If A : B in the hierarchy, then A must “extend” the
RULE behavior/functionalities/properties of B
behavior/functionalities/properties 144 Quick summary
x How a method/attribute can be accessed outside the
How current class is determined by public/protected/private
current Protected attributes/metho...
View Full Document
This note was uploaded on 04/03/2014 for the course CS 31 taught by Professor Melkanoff during the Fall '00 term at UCLA.
- Fall '00