Please enable JavaScript.
Coggle requires JavaScript to display documents.
07 Inheritance towards polymorphism (Principle of substitutibility…
07
Inheritance
towards polymorphism
Constructors
in derived classes
Not inherited!
Default constructor of base class is called
Can invoke alternative base class constructor via : base(...)
Principle of
substitutibility
Object of derived type should be able to be used
wherever an object of base type was expected
(because it just "adds" extra features)
Can use base type reference to refer to
object of derived type
Take base type as parameter to method
Return base type from method
Store collection of base type references
References include what type they are
Polymorphism and
polymorphic method calls
Base method marked as virtual
Derived method marked as override
Actual method called decided at runtime
Casting
references
Downcasting via (type)
Downcasting safely via "is" or "as"
Labs
Testing racing cars
Employee hierarchy
Traffic light simulator