Diamond Problem Class Diagram A B C D Two paths to A in D! Ambiguity without virtual inheritance
Comprehensive Zoo Class Inheritance Diagram Zoo Class Inheritance Hierarchy Animal + name: string + age: int + makeSound() Mammal + furColor: string + giveBirth() Bird + wingspan: float + fly() Reptile + scaleType: string + shedSkin() Aquatic + depth: int + swim() Flying + maxAltitude: int + takeOff() Lion + roar() Elephant + trumpet() Snake + slither() Shark + hunt() Eagle + dive() Bat + echolocate() Platypus + layEggs() Penguin + waddle() Legend Base Class - Root of hierarchy (Animal) Intermediate Classes - Shared traits (Mammal, Bird, etc.) Concrete Classes - Single inheritance (Lion, Elephant, Snake, etc.) Multiple Inheritance - Inherits from 2+ classes (Bat, Platypus, Penguin) Note: Multiple inheritance should use virtual inheritance to avoid diamond problem

Navigation

Back to Course Outline
Previous: Friend Functions and Inheritance