Download presentation
Presentation is loading. Please wait.
1
(C) Copyright 1999-2001. All Rights Reserved.1 Example
2
(C) Copyright 1999-2001. All Rights Reserved.2 Example Suppose that we have an instance of A and that A::h precedes A::i and A::j
3
(C) Copyright 1999-2001. All Rights Reserved.3 Example Different def sets Suppose that we now have an instance of B.
4
(C) Copyright 1999-2001. All Rights Reserved.4 Example If A::h can precede A::i, then a data flow anomaly exists
5
(C) Copyright 1999-2001. All Rights Reserved.5 Consider what happens when the type of the instance varies Example
6
(C) Copyright 1999-2001. All Rights Reserved.6 Polymorphism Headaches (Yo-Yo) A +d () +g () +h () +i () +j () +l () Instantiated type B k() h()i() C j()i()l() A d()j()g()h()i()l() implicit d is called through an instance of type A (I.e. o is bound to some instance of A)
7
(C) Copyright 1999-2001. All Rights Reserved.7 Polymorphism Headaches (Yo-Yo) A +d () +g () +h () +i () +j () +l () B +h () +i () +k () B h()i()k() implicit B k() h()i() C j()i()l() A d() j() g()h()i()l() C j()i()l() A d()j()g()h()i()l() implicit d is called through an instance of type B Instantiated type explicit
8
(C) Copyright 1999-2001. All Rights Reserved.8 A +d () +g () +h () +i () +j () +l () B +h () +i () +k () B h()i()k() implicit B k() h()i() C j()i()l() A d() j() g()h()i()l() C j()i()l() A d()j()g()h()i()l() implicit Instantiated type Polymorphism Headaches (Yo-Yo) A::i with respect to A::u A::j with respect to A::w d is called through an instance of type B explicit
9
(C) Copyright 1999-2001. All Rights Reserved.9 Polymorphism Headaches (Yo-Yo) A +d () +g () +h () +i () +j () +l () B +h () +i () +k () C +i () +j () +l () C j()i()l() B h()i()k() implicit Instantiated type B k() h()i() C j()i()l() A d()j()g()h()i()l() C j()i()l() A d()j()g()h()i()l() B h()i() k() A d()j()g()h()i()l() implicit explicit d is called through an instance of type C
10
(C) Copyright 1999-2001. All Rights Reserved.10 Polymorphism Headaches (Yo-Yo) A +d () +g () +h () +i () +j () +l () B +h () +i () +k () C +i () +j () +l () C j()i()l() B h()i()k() implicit Instantiated type B k() h()i() C j()i()l() A d()j()g()h()i()l() C j()i()l() A d()j()g()h()i()l() B h()i() k() A d()j()g()h()i()l() implicit explicit A::i with respect to A::u C::l with respect to A::v d is called through an instance of type C
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.