cs31 lecture 17

The other x usually both are needed eg b a and b has

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 Strong 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 B” x Example: “a rectangle is a square” vs. “a rectangle is an Example: object” 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.

Ask a homework question - tutors are online