05-multipleinheritance

05-multipleinheritance - CS4240 AaronBloomfield...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style CS 4240 Principles of Software Design Aaron Bloomfield Multiple Inheritance & Interfaces Fall 2009
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Click to edit Master subtitle style 22 Motivation for multiple inheritance  (MI)
Background image of page 2
33
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
44 Review: overloading vs. overriding n Overloading class foo { void bar () { … } void bar (int a) { … } void bar (float f) { … } void bar (int a, int b)  { … } } Overriding void bar() { … } } class quz : public foo { void bar() { … }
Background image of page 4
55 Motivation n UVSphere extends Shape n But it also needs to extend Subject n And Aggregate (from the Iterator pattern) n For iterating through the points/faces/edges n And others n With multiple inheritance: class UVSphere : public Shape, public Subject,  public Aggregate {
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
66 Using MI for Observers n Now, the following method prototype: n public void Update (Subject* theChagnedSubject); n Can take in any UVSphere
Background image of page 6
77 Problems with multiple inheritance class A { void foo(); } class B { } class C: public A, public B { // which foo() does it use? }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
88 More problems class A { void foo(); } class B { int  foo(); } class C: public A, public B { // what is the return type of foo()? }
Background image of page 8
99 Even more problems n Consider this class diagram: n gp_list_node is an ancestor class twice!!! gp_list_n ode pers on studen t gp_list_nod student_pr of professo
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Click to edit Master subtitle style 1010 Multiple inheritance details
Background image of page 10
1111 Multiple Inheritance n Derived class with two or more base classes n E.g. - Student class n C++: class student : public person, public gp_list_node { … }
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1212 Languages supporting MI n Supported in C++, Eiffel, CLOS n
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/25/2009 for the course CS 4240 taught by Professor Aronbloomfiled during the Spring '09 term at UVA.

Page1 / 38

05-multipleinheritance - CS4240 AaronBloomfield...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online